@agent-native/core 0.107.2 → 0.108.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.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/docs/content/actions.mdx +48 -0
- package/corpus/core/docs/content/locales/ar-SA/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/de-DE/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/es-ES/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/fr-FR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/hi-IN/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/ja-JP/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/ko-KR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/pt-BR/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/zh-CN/actions.mdx +38 -0
- package/corpus/core/docs/content/locales/zh-TW/actions.mdx +38 -0
- package/corpus/core/package.json +5 -1
- package/corpus/core/src/a2a-claims.ts +52 -0
- package/corpus/core/src/action.ts +6 -2
- package/corpus/core/src/audit/record.ts +6 -0
- package/corpus/core/src/client/feature-flags/FeatureFlagsPanel.tsx +519 -0
- package/corpus/core/src/client/feature-flags/helpers.ts +77 -0
- package/corpus/core/src/client/feature-flags/index.ts +13 -0
- package/corpus/core/src/client/feature-flags/types.ts +29 -0
- package/corpus/core/src/client/feature-flags/use-feature-flag.ts +26 -0
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/extensions/routes.ts +1 -1
- package/corpus/core/src/feature-flags/a2a-action-route.ts +56 -0
- package/corpus/core/src/feature-flags/actions/get-feature-flags.ts +24 -0
- package/corpus/core/src/feature-flags/actions/list-feature-flags.ts +69 -0
- package/corpus/core/src/feature-flags/actions/set-feature-flag.ts +89 -0
- package/corpus/core/src/feature-flags/index.ts +21 -0
- package/corpus/core/src/feature-flags/permissions.ts +53 -0
- package/corpus/core/src/feature-flags/plugin.ts +44 -0
- package/corpus/core/src/feature-flags/registry.ts +96 -0
- package/corpus/core/src/feature-flags/store.ts +176 -0
- package/corpus/core/src/index.ts +15 -0
- package/corpus/core/src/localization/default-messages.ts +47 -0
- package/corpus/core/src/server/action-discovery.ts +12 -0
- package/corpus/core/src/server/action-routes.ts +47 -5
- package/corpus/core/src/server/index.ts +1 -0
- package/corpus/core/src/settings/org-settings.ts +13 -0
- package/corpus/core/src/settings/store.ts +57 -0
- package/corpus/core/src/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/default/AGENTS.md +1 -0
- package/corpus/core/src/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +1 -1
- package/corpus/core/src/templates/workspace-root/AGENTS.md +1 -1
- package/corpus/core/src/vite/action-types-plugin.ts +12 -0
- package/corpus/templates/analytics/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/analytics/AGENTS.md +15 -3
- package/corpus/templates/analytics/actions/list-workspace-feature-flags.ts +15 -0
- package/corpus/templates/analytics/actions/navigate.ts +2 -2
- package/corpus/templates/analytics/actions/set-workspace-feature-flag.ts +45 -0
- package/corpus/templates/analytics/actions/view-screen.ts +13 -0
- package/corpus/templates/analytics/app/components/agents/FeatureFlagsFleetPanel.tsx +243 -0
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +11 -3
- package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +3 -1
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +17 -0
- package/corpus/templates/analytics/app/i18n-data.ts +251 -0
- package/corpus/templates/analytics/app/pages/Agents.tsx +22 -2
- package/corpus/templates/analytics/changelog/2026-07-17-manage-feature-flag-rollouts-across-your-organization-s-apps.md +6 -0
- package/corpus/templates/analytics/server/lib/db-admin-connections.ts +13 -5
- package/corpus/templates/analytics/server/lib/workspace-feature-flags.ts +347 -0
- package/corpus/templates/assets/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/brain/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/calendar/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/clips/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/clips/server/plugins/feature-flags.ts +11 -0
- package/corpus/templates/clips/shared/feature-flags.ts +30 -37
- package/corpus/templates/content/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/design/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/design/AGENTS.md +5 -3
- package/corpus/templates/design/actions/add-fusion-screens.ts +4 -6
- package/corpus/templates/design/actions/apply-fusion-edits.ts +4 -6
- package/corpus/templates/design/actions/create-fusion-app.ts +5 -4
- package/corpus/templates/design/actions/deploy-fusion-app.ts +4 -3
- package/corpus/templates/design/actions/get-fusion-deploy-status.ts +4 -6
- package/corpus/templates/design/actions/list-fusion-edits.ts +4 -3
- package/corpus/templates/design/actions/push-fusion-app.ts +4 -6
- package/corpus/templates/design/actions/queue-fusion-edit.ts +4 -3
- package/corpus/templates/design/actions/send-fusion-message.ts +4 -6
- package/corpus/templates/design/actions/sync-fusion-app.ts +4 -3
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +1 -1
- package/corpus/templates/design/app/pages/Index.tsx +8 -6
- package/corpus/templates/design/server/plugins/feature-flags.ts +5 -0
- package/corpus/templates/design/shared/full-app.ts +10 -7
- package/corpus/templates/dispatch/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/forms/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/macros/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/mail/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/plan/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/slides/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/tasks/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/a2a-claims.d.ts +10 -0
- package/dist/a2a-claims.d.ts.map +1 -0
- package/dist/a2a-claims.js +41 -0
- package/dist/a2a-claims.js.map +1 -0
- package/dist/action.d.ts +6 -2
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/audit/record.d.ts +3 -0
- package/dist/audit/record.d.ts.map +1 -1
- package/dist/audit/record.js +3 -0
- package/dist/audit/record.js.map +1 -1
- package/dist/client/feature-flags/FeatureFlagsPanel.d.ts +10 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.d.ts.map +1 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.js +143 -0
- package/dist/client/feature-flags/FeatureFlagsPanel.js.map +1 -0
- package/dist/client/feature-flags/helpers.d.ts +16 -0
- package/dist/client/feature-flags/helpers.d.ts.map +1 -0
- package/dist/client/feature-flags/helpers.js +50 -0
- package/dist/client/feature-flags/helpers.js.map +1 -0
- package/dist/client/feature-flags/index.d.ts +5 -0
- package/dist/client/feature-flags/index.d.ts.map +1 -0
- package/dist/client/feature-flags/index.js +4 -0
- package/dist/client/feature-flags/index.js.map +1 -0
- package/dist/client/feature-flags/types.d.ts +27 -0
- package/dist/client/feature-flags/types.d.ts.map +1 -0
- package/dist/client/feature-flags/types.js +2 -0
- package/dist/client/feature-flags/types.js.map +1 -0
- package/dist/client/feature-flags/use-feature-flag.d.ts +8 -0
- package/dist/client/feature-flags/use-feature-flag.d.ts.map +1 -0
- package/dist/client/feature-flags/use-feature-flag.js +15 -0
- package/dist/client/feature-flags/use-feature-flag.js.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +1 -1
- package/dist/extensions/routes.js.map +1 -1
- package/dist/feature-flags/a2a-action-route.d.ts +14 -0
- package/dist/feature-flags/a2a-action-route.d.ts.map +1 -0
- package/dist/feature-flags/a2a-action-route.js +50 -0
- package/dist/feature-flags/a2a-action-route.js.map +1 -0
- package/dist/feature-flags/actions/get-feature-flags.d.ts +3 -0
- package/dist/feature-flags/actions/get-feature-flags.d.ts.map +1 -0
- package/dist/feature-flags/actions/get-feature-flags.js +18 -0
- package/dist/feature-flags/actions/get-feature-flags.js.map +1 -0
- package/dist/feature-flags/actions/list-feature-flags.d.ts +28 -0
- package/dist/feature-flags/actions/list-feature-flags.d.ts.map +1 -0
- package/dist/feature-flags/actions/list-feature-flags.js +60 -0
- package/dist/feature-flags/actions/list-feature-flags.js.map +1 -0
- package/dist/feature-flags/actions/set-feature-flag.d.ts +26 -0
- package/dist/feature-flags/actions/set-feature-flag.d.ts.map +1 -0
- package/dist/feature-flags/actions/set-feature-flag.js +78 -0
- package/dist/feature-flags/actions/set-feature-flag.js.map +1 -0
- package/dist/feature-flags/index.d.ts +5 -0
- package/dist/feature-flags/index.d.ts.map +1 -0
- package/dist/feature-flags/index.js +5 -0
- package/dist/feature-flags/index.js.map +1 -0
- package/dist/feature-flags/permissions.d.ts +13 -0
- package/dist/feature-flags/permissions.d.ts.map +1 -0
- package/dist/feature-flags/permissions.js +37 -0
- package/dist/feature-flags/permissions.js.map +1 -0
- package/dist/feature-flags/plugin.d.ts +17 -0
- package/dist/feature-flags/plugin.d.ts.map +1 -0
- package/dist/feature-flags/plugin.js +29 -0
- package/dist/feature-flags/plugin.js.map +1 -0
- package/dist/feature-flags/registry.d.ts +23 -0
- package/dist/feature-flags/registry.d.ts.map +1 -0
- package/dist/feature-flags/registry.js +59 -0
- package/dist/feature-flags/registry.js.map +1 -0
- package/dist/feature-flags/store.d.ts +31 -0
- package/dist/feature-flags/store.d.ts.map +1 -0
- package/dist/feature-flags/store.js +124 -0
- package/dist/feature-flags/store.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/localization/default-messages.d.ts +42 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +42 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +12 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts +3 -0
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +45 -5
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/settings/org-settings.d.ts +2 -0
- package/dist/settings/org-settings.d.ts.map +1 -1
- package/dist/settings/org-settings.js +5 -1
- package/dist/settings/org-settings.js.map +1 -1
- package/dist/settings/store.d.ts +8 -0
- package/dist/settings/store.d.ts.map +1 -1
- package/dist/settings/store.js +48 -0
- package/dist/settings/store.js.map +1 -1
- package/dist/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/default/AGENTS.md +1 -0
- package/dist/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/dist/templates/workspace-core/AGENTS.md +1 -1
- package/dist/templates/workspace-root/AGENTS.md +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +12 -0
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/docs/content/actions.mdx +48 -0
- package/docs/content/locales/ar-SA/actions.mdx +38 -0
- package/docs/content/locales/de-DE/actions.mdx +38 -0
- package/docs/content/locales/es-ES/actions.mdx +38 -0
- package/docs/content/locales/fr-FR/actions.mdx +38 -0
- package/docs/content/locales/hi-IN/actions.mdx +38 -0
- package/docs/content/locales/ja-JP/actions.mdx +38 -0
- package/docs/content/locales/ko-KR/actions.mdx +38 -0
- package/docs/content/locales/pt-BR/actions.mdx +38 -0
- package/docs/content/locales/zh-CN/actions.mdx +38 -0
- package/docs/content/locales/zh-TW/actions.mdx +38 -0
- package/package.json +5 -1
- package/src/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/default/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/default/AGENTS.md +1 -0
- package/src/templates/headless/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +169 -0
- package/src/templates/workspace-core/AGENTS.md +1 -1
- package/src/templates/workspace-root/AGENTS.md +1 -1
- package/corpus/templates/clips/actions/get-feature-flags.ts +0 -30
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,sCAAsC,EACtC,4CAA4C,EAC5C,oCAAoC,GACrC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,gCAAgC,EAChC,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GAEpB,MAAM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,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EAChC,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,gBAAgB,EAChB,4BAA4B,GAM7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oCAAoC,EACpC,mCAAmC,EACnC,mCAAmC,EACnC,0CAA0C,EAC1C,eAAe,GAGhB,MAAM,sCAAsC,CAAC;AAW9C,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["export {\n createServer,\n type CreateServerOptions,\n type EnvKeyConfig,\n} from \"./create-server.js\";\nexport {\n AGENT_BACKGROUND_PROCESSOR_FIELD,\n AGENT_BACKGROUND_PROCESSOR_ROUTE,\n AGENT_BACKGROUND_PROCESSOR_ROUTE_FIELD,\n dispatchPathTargetsNetlifyBackgroundFunction,\n resolveDurableBackgroundDispatchPath,\n} from \"../agent/durable-background.js\";\n\nexport {\n readBody,\n readBodyWithSizeLimit,\n streamFile,\n DEFAULT_CHAT_MAX_BODY_BYTES,\n DEFAULT_UPLOAD_MAX_FILE_BYTES,\n MAX_CHAT_ATTACHMENTS_PER_MESSAGE,\n isAllowedUploadMimeType,\n} from \"./h3-helpers.js\";\nexport {\n buildDeepLink,\n toAbsoluteOpenUrl,\n toDesktopOpenUrl,\n toVsCodeOpenUrl,\n OPEN_ROUTE_SUBPATH,\n DESKTOP_OPEN_URL,\n VSCODE_OPEN_URL,\n type DeepLinkInput,\n} from \"./deep-link.js\";\nexport { createOpenRouteHandler, type OpenRouteOptions } from \"./open-route.js\";\nexport {\n createEmbedStartRouteHandler,\n buildEmbedStartPath,\n type EmbedStartRouteOptions,\n} from \"./embed-route.js\";\nexport {\n createEmbedSessionTicket,\n consumeEmbedSessionTicket,\n normalizeEmbedTargetPath,\n requestHasEmbedAuthMarker,\n resolveEmbedSessionFromRequest,\n setEmbedSessionCookie,\n signEmbedSessionToken,\n verifyEmbedSessionToken,\n type ConsumedEmbedSessionTicket,\n type ConsumeEmbedSessionTicketOptions,\n type EmbedSessionTicket,\n type EmbedSessionTicketInput,\n type EmbedSessionTokenClaims,\n type ResolvedEmbedSession,\n type VerifyEmbedSessionTokenResult,\n} from \"./embed-session.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n COOKIE_NAME,\n addSession,\n removeSession,\n getSessionEmail,\n getFrameworkSessionCookieValues,\n setFrameworkSessionCookie,\n clearFrameworkSessionCookies,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport {\n handleIdentitySso,\n getIdentityHubUrl,\n isIdentitySsoEnabled,\n isIdentitySsoBypassPath,\n identitySsoLoginButtonHtml,\n IDENTITY_SSO_PROVIDER_ID,\n IDENTITY_SSO_SCOPE,\n} from \"./identity-sso.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport {\n assertCurrentRequestUserIsOrgAdmin,\n currentRequestUserIsOrgAdmin,\n} from \"./org-admin.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n getLocaleInitScript,\n parseAcceptLanguage,\n resolveLocaleFromRequest,\n type LocaleInitScriptOptions,\n type ResolveLocaleFromRequestOptions,\n type ResolvedRequestLocale,\n} from \"../localization/server.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n executeAgentToolCall,\n getOwnerActiveApiKey,\n runAgentLoop,\n type AgentToolCallExecutionResult,\n type ExecuteAgentToolCallOptions,\n} from \"../agent/production-agent.js\";\nexport {\n mountRealtimeVoiceRoutes,\n realtimeVoiceSafetyIdentifier,\n REALTIME_VOICE_MAX_SDP_BYTES,\n REALTIME_VOICE_MAX_TOOL_BODY_BYTES,\n REALTIME_VOICE_MAX_TOOL_OUTPUT_CHARS,\n REALTIME_VOICE_SESSION_PATH,\n REALTIME_VOICE_TOOL_PATH,\n type MountRealtimeVoiceRoutesOptions,\n type RealtimeVoiceRequestContext,\n type RealtimeVoiceToolExecutionRequest,\n type RealtimeVoiceToolExecutionResult,\n} from \"./realtime-voice.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport {\n completeText,\n type CompleteTextMessage,\n type CompleteTextOptions,\n type CompleteTextResult,\n type CompleteTextUsage,\n} from \"./complete-text.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createContextXrayPlugin,\n defaultContextXrayPlugin,\n} from \"../agent/context-xray/plugin.js\";\nexport {\n createObservationalMemoryPlugin,\n defaultObservationalMemoryPlugin,\n} from \"../agent/observational-memory/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n refreshGlobalMcpManager,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadArchived,\n setThreadPinned,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL,\n AGENT_NATIVE_OG_IMAGE_HEIGHT,\n AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL,\n AGENT_NATIVE_OG_IMAGE_WIDTH,\n agentNativeOgImageResponseHeaders,\n createAgentNativeOgImageHandler,\n renderAgentNativeOgImagePng,\n renderAgentNativeOgImageSvg,\n type AgentNativeOgImageInput,\n} from \"./social-og-image.js\";\nexport { resolveOgFontFiles } from \"./og-fonts.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport {\n hasGoogleSignInCredentials,\n resolveGoogleLegacyProviderCredentials,\n resolveGoogleProviderCredentialCandidates,\n resolveGoogleProviderCredentials,\n resolveGoogleSignInCredentials,\n type GoogleOAuthCredentials,\n} from \"./google-oauth-credentials.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n markDefaultPluginProvided,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n fireInternalDispatch,\n resolveSelfDispatchBaseUrl,\n type FireInternalDispatchOptions,\n} from \"./self-dispatch.js\";\nexport {\n extractBearerToken as extractInternalBearerToken,\n verifyInternalToken,\n} from \"../integrations/internal-token.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n registerPromptContextProvider,\n type PromptContextProvider,\n type PromptContextProviderContext,\n type PromptContextProviderContribution,\n} from \"./agent-chat/prompt-resources.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n type ActionRouteAuthAdapter,\n type ActionRouteResolvedCaller,\n} from \"./action-routes.js\";\nexport {\n AGENT_RUN_OWNER_CONTEXT_KEY,\n seedAgentRunOwnerContext,\n type AgentRunOwnerContext,\n} from \"./agent-run-context.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n getActiveFileUploadProviderForRequest,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n discordAdapter,\n microsoftTeamsAdapter,\n emailAdapter,\n assertPlatformCapability,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type PlatformAdapterCapabilities,\n type ImmediateWebhookResponse,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n type IntegrationExecutionContext,\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n buildWorkspaceProviderAuthorizationUrl,\n createWorkspaceProviderOAuthHandler,\n exchangeWorkspaceProviderOAuthCode,\n handleWorkspaceProviderOAuthCallback,\n handleWorkspaceProviderOAuthStart,\n isWorkspaceProviderOAuthFlowValid,\n mergeWorkspaceOAuthValues,\n resolveWorkspaceProviderIdentity,\n workspaceProviderOAuthPath,\n type GenericWorkspaceOAuthProvider,\n type WorkspaceProviderOAuthFlow,\n} from \"./workspace-provider-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderWebSearchBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveHasCompleteBuilderConnection,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n readDeployCredentialEnv,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n builderDesignSystemUrl,\n buildBuilderDesignSystemIndexFiles,\n createBuilderDesignSystemProxyFields,\n fetchBuilderDesignSystemDocs,\n getBuilderDesignSystemsBaseUrl,\n hydrateBuilderDesignSystemReference,\n localBuilderDesignSystemId,\n mimeTypeForBuilderDesignSystemFilename,\n parseBuilderDesignSystemProxyReference,\n startBuilderDesignSystemIndex,\n type BuildBuilderDesignSystemIndexFilesOptions,\n type BuilderDesignSystemCodeFileInput,\n type BuilderDesignSystemDocsOptions,\n type BuilderDesignSystemDocument,\n type BuilderDesignSystemHydratedReference,\n type BuilderDesignSystemIndexFile,\n type BuilderDesignSystemIndexOptions,\n type BuilderDesignSystemIndexResult,\n type BuilderDesignSystemProxyFields,\n type BuilderDesignSystemProxyFieldsOptions,\n type BuilderDesignSystemProxyReference,\n} from \"./builder-design-systems.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n requestBuilderBrowserConnection,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\nexport {\n ensureFusionContainer,\n sendFusionBranchMessage,\n pushFusionBranch,\n reserveFusionHostingSlug,\n deployFusionProject,\n getFusionDeploys,\n getFusionBranchEditorUrl,\n getFusionHostingUrl,\n type FusionBranchRef,\n type EnsureFusionContainerResult,\n type SendFusionMessageResult,\n} from \"./fusion-app.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailAttachment,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\nexport {\n AGENT_ACCESS_PARAM,\n DEFAULT_AGENT_ACCESS_TTL_SECONDS,\n appendAgentAccessParam,\n buildAgentAccessApiUrl,\n buildAgentAccessUrl,\n createScopedAgentAccessGrant,\n normalizeAgentAccessBasePath,\n normalizeAgentAccessOrigin,\n scopedAgentAccessResourceId,\n signScopedAgentAccessToken,\n toAgentAccessUrl,\n verifyScopedAgentAccessToken,\n type AgentAccessApiUrlOptions,\n type AgentAccessResourceScope,\n type AgentAccessUrlOptions,\n type ScopedAgentAccessGrant,\n type ScopedAgentAccessTokenOptions,\n} from \"./agent-access.js\";\nexport {\n AGENT_READABLE_RESOURCE_PAYLOAD_TYPE,\n AGENT_READABLE_RESOURCE_SCRIPT_TYPE,\n buildAgentReadableResourceDiscovery,\n renderAgentReadableResourceDiscoveryScript,\n safeJsonForHtml,\n type AgentReadableResourceDiscovery,\n type BuildAgentReadableResourceDiscoveryOptions,\n} from \"../shared/agent-readable-resource.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,sCAAsC,EACtC,4CAA4C,EAC5C,oCAAoC,GACrC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,gCAAgC,EAChC,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GAQxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAA0B,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,+BAA+B,EAC/B,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAIf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,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"./create-server.js\";\nexport {\n AGENT_BACKGROUND_PROCESSOR_FIELD,\n AGENT_BACKGROUND_PROCESSOR_ROUTE,\n AGENT_BACKGROUND_PROCESSOR_ROUTE_FIELD,\n dispatchPathTargetsNetlifyBackgroundFunction,\n resolveDurableBackgroundDispatchPath,\n} from \"../agent/durable-background.js\";\n\nexport {\n readBody,\n readBodyWithSizeLimit,\n streamFile,\n DEFAULT_CHAT_MAX_BODY_BYTES,\n DEFAULT_UPLOAD_MAX_FILE_BYTES,\n MAX_CHAT_ATTACHMENTS_PER_MESSAGE,\n isAllowedUploadMimeType,\n} from \"./h3-helpers.js\";\nexport {\n buildDeepLink,\n toAbsoluteOpenUrl,\n toDesktopOpenUrl,\n toVsCodeOpenUrl,\n OPEN_ROUTE_SUBPATH,\n DESKTOP_OPEN_URL,\n VSCODE_OPEN_URL,\n type DeepLinkInput,\n} from \"./deep-link.js\";\nexport { createOpenRouteHandler, type OpenRouteOptions } from \"./open-route.js\";\nexport {\n createEmbedStartRouteHandler,\n buildEmbedStartPath,\n type EmbedStartRouteOptions,\n} from \"./embed-route.js\";\nexport {\n createEmbedSessionTicket,\n consumeEmbedSessionTicket,\n normalizeEmbedTargetPath,\n requestHasEmbedAuthMarker,\n resolveEmbedSessionFromRequest,\n setEmbedSessionCookie,\n signEmbedSessionToken,\n verifyEmbedSessionToken,\n type ConsumedEmbedSessionTicket,\n type ConsumeEmbedSessionTicketOptions,\n type EmbedSessionTicket,\n type EmbedSessionTicketInput,\n type EmbedSessionTokenClaims,\n type ResolvedEmbedSession,\n type VerifyEmbedSessionTokenResult,\n} from \"./embed-session.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n COOKIE_NAME,\n addSession,\n removeSession,\n getSessionEmail,\n getFrameworkSessionCookieValues,\n setFrameworkSessionCookie,\n clearFrameworkSessionCookies,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport {\n handleIdentitySso,\n getIdentityHubUrl,\n isIdentitySsoEnabled,\n isIdentitySsoBypassPath,\n identitySsoLoginButtonHtml,\n IDENTITY_SSO_PROVIDER_ID,\n IDENTITY_SSO_SCOPE,\n} from \"./identity-sso.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport {\n assertCurrentRequestUserIsOrgAdmin,\n currentRequestUserIsOrgAdmin,\n} from \"./org-admin.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n getLocaleInitScript,\n parseAcceptLanguage,\n resolveLocaleFromRequest,\n type LocaleInitScriptOptions,\n type ResolveLocaleFromRequestOptions,\n type ResolvedRequestLocale,\n} from \"../localization/server.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n executeAgentToolCall,\n getOwnerActiveApiKey,\n runAgentLoop,\n type AgentToolCallExecutionResult,\n type ExecuteAgentToolCallOptions,\n} from \"../agent/production-agent.js\";\nexport {\n mountRealtimeVoiceRoutes,\n realtimeVoiceSafetyIdentifier,\n REALTIME_VOICE_MAX_SDP_BYTES,\n REALTIME_VOICE_MAX_TOOL_BODY_BYTES,\n REALTIME_VOICE_MAX_TOOL_OUTPUT_CHARS,\n REALTIME_VOICE_SESSION_PATH,\n REALTIME_VOICE_TOOL_PATH,\n type MountRealtimeVoiceRoutesOptions,\n type RealtimeVoiceRequestContext,\n type RealtimeVoiceToolExecutionRequest,\n type RealtimeVoiceToolExecutionResult,\n} from \"./realtime-voice.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport {\n completeText,\n type CompleteTextMessage,\n type CompleteTextOptions,\n type CompleteTextResult,\n type CompleteTextUsage,\n} from \"./complete-text.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport { createFeatureFlagsPlugin } from \"../feature-flags/plugin.js\";\nexport {\n createContextXrayPlugin,\n defaultContextXrayPlugin,\n} from \"../agent/context-xray/plugin.js\";\nexport {\n createObservationalMemoryPlugin,\n defaultObservationalMemoryPlugin,\n} from \"../agent/observational-memory/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n refreshGlobalMcpManager,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadArchived,\n setThreadPinned,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL,\n AGENT_NATIVE_OG_IMAGE_HEIGHT,\n AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL,\n AGENT_NATIVE_OG_IMAGE_WIDTH,\n agentNativeOgImageResponseHeaders,\n createAgentNativeOgImageHandler,\n renderAgentNativeOgImagePng,\n renderAgentNativeOgImageSvg,\n type AgentNativeOgImageInput,\n} from \"./social-og-image.js\";\nexport { resolveOgFontFiles } from \"./og-fonts.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport {\n hasGoogleSignInCredentials,\n resolveGoogleLegacyProviderCredentials,\n resolveGoogleProviderCredentialCandidates,\n resolveGoogleProviderCredentials,\n resolveGoogleSignInCredentials,\n type GoogleOAuthCredentials,\n} from \"./google-oauth-credentials.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n markDefaultPluginProvided,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n fireInternalDispatch,\n resolveSelfDispatchBaseUrl,\n type FireInternalDispatchOptions,\n} from \"./self-dispatch.js\";\nexport {\n extractBearerToken as extractInternalBearerToken,\n verifyInternalToken,\n} from \"../integrations/internal-token.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n registerPromptContextProvider,\n type PromptContextProvider,\n type PromptContextProviderContext,\n type PromptContextProviderContribution,\n} from \"./agent-chat/prompt-resources.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n type ActionRouteAuthAdapter,\n type ActionRouteResolvedCaller,\n} from \"./action-routes.js\";\nexport {\n AGENT_RUN_OWNER_CONTEXT_KEY,\n seedAgentRunOwnerContext,\n type AgentRunOwnerContext,\n} from \"./agent-run-context.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n getActiveFileUploadProviderForRequest,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n discordAdapter,\n microsoftTeamsAdapter,\n emailAdapter,\n assertPlatformCapability,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type PlatformAdapterCapabilities,\n type ImmediateWebhookResponse,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n type IntegrationExecutionContext,\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n buildWorkspaceProviderAuthorizationUrl,\n createWorkspaceProviderOAuthHandler,\n exchangeWorkspaceProviderOAuthCode,\n handleWorkspaceProviderOAuthCallback,\n handleWorkspaceProviderOAuthStart,\n isWorkspaceProviderOAuthFlowValid,\n mergeWorkspaceOAuthValues,\n resolveWorkspaceProviderIdentity,\n workspaceProviderOAuthPath,\n type GenericWorkspaceOAuthProvider,\n type WorkspaceProviderOAuthFlow,\n} from \"./workspace-provider-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderWebSearchBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveHasCompleteBuilderConnection,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n readDeployCredentialEnv,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n builderDesignSystemUrl,\n buildBuilderDesignSystemIndexFiles,\n createBuilderDesignSystemProxyFields,\n fetchBuilderDesignSystemDocs,\n getBuilderDesignSystemsBaseUrl,\n hydrateBuilderDesignSystemReference,\n localBuilderDesignSystemId,\n mimeTypeForBuilderDesignSystemFilename,\n parseBuilderDesignSystemProxyReference,\n startBuilderDesignSystemIndex,\n type BuildBuilderDesignSystemIndexFilesOptions,\n type BuilderDesignSystemCodeFileInput,\n type BuilderDesignSystemDocsOptions,\n type BuilderDesignSystemDocument,\n type BuilderDesignSystemHydratedReference,\n type BuilderDesignSystemIndexFile,\n type BuilderDesignSystemIndexOptions,\n type BuilderDesignSystemIndexResult,\n type BuilderDesignSystemProxyFields,\n type BuilderDesignSystemProxyFieldsOptions,\n type BuilderDesignSystemProxyReference,\n} from \"./builder-design-systems.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n requestBuilderBrowserConnection,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\nexport {\n ensureFusionContainer,\n sendFusionBranchMessage,\n pushFusionBranch,\n reserveFusionHostingSlug,\n deployFusionProject,\n getFusionDeploys,\n getFusionBranchEditorUrl,\n getFusionHostingUrl,\n type FusionBranchRef,\n type EnsureFusionContainerResult,\n type SendFusionMessageResult,\n} from \"./fusion-app.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailAttachment,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\nexport {\n AGENT_ACCESS_PARAM,\n DEFAULT_AGENT_ACCESS_TTL_SECONDS,\n appendAgentAccessParam,\n buildAgentAccessApiUrl,\n buildAgentAccessUrl,\n createScopedAgentAccessGrant,\n normalizeAgentAccessBasePath,\n normalizeAgentAccessOrigin,\n scopedAgentAccessResourceId,\n signScopedAgentAccessToken,\n toAgentAccessUrl,\n verifyScopedAgentAccessToken,\n type AgentAccessApiUrlOptions,\n type AgentAccessResourceScope,\n type AgentAccessUrlOptions,\n type ScopedAgentAccessGrant,\n type ScopedAgentAccessTokenOptions,\n} from \"./agent-access.js\";\nexport {\n AGENT_READABLE_RESOURCE_PAYLOAD_TYPE,\n AGENT_READABLE_RESOURCE_SCRIPT_TYPE,\n buildAgentReadableResourceDiscovery,\n renderAgentReadableResourceDiscoveryScript,\n safeJsonForHtml,\n type AgentReadableResourceDiscovery,\n type BuildAgentReadableResourceDiscoveryOptions,\n} from \"../shared/agent-readable-resource.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
@@ -12,6 +12,8 @@ import { type StoreWriteOptions } from "./store.js";
|
|
|
12
12
|
export declare function getOrgSetting(orgId: string, key: string): Promise<Record<string, unknown> | null>;
|
|
13
13
|
/** Write an org-scoped setting. Always writes to the prefixed key. */
|
|
14
14
|
export declare function putOrgSetting(orgId: string, key: string, value: Record<string, unknown>, options?: StoreWriteOptions): Promise<void>;
|
|
15
|
+
/** Atomically derive and persist an org-scoped setting. */
|
|
16
|
+
export declare function mutateOrgSetting(orgId: string, key: string, updater: (current: Record<string, unknown> | null) => Record<string, unknown> | Promise<Record<string, unknown>>, options?: StoreWriteOptions): Promise<Record<string, unknown>>;
|
|
15
17
|
/** Delete an org-scoped setting. */
|
|
16
18
|
export declare function deleteOrgSetting(orgId: string, key: string, options?: StoreWriteOptions): Promise<boolean>;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"org-settings.d.ts","sourceRoot":"","sources":["../../src/settings/org-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"org-settings.d.ts","sourceRoot":"","sources":["../../src/settings/org-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAQpB,wEAAwE;AACxE,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAEzC;AAED,sEAAsE;AACtE,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,2DAA2D;AAC3D,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CACP,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC/D,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAElC;AAED,oCAAoC;AACpC,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAWlD"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* No global fallback — each org starts with a clean slate. This
|
|
8
8
|
* prevents one org's data from leaking to another.
|
|
9
9
|
*/
|
|
10
|
-
import { getSetting, putSetting, deleteSetting, getAllSettings, } from "./store.js";
|
|
10
|
+
import { getSetting, mutateSetting, putSetting, deleteSetting, getAllSettings, } from "./store.js";
|
|
11
11
|
function orgKey(orgId, key) {
|
|
12
12
|
return `o:${orgId}:${key}`;
|
|
13
13
|
}
|
|
@@ -20,6 +20,10 @@ export async function getOrgSetting(orgId, key) {
|
|
|
20
20
|
export async function putOrgSetting(orgId, key, value, options) {
|
|
21
21
|
return putSetting(orgKey(orgId, key), value, options);
|
|
22
22
|
}
|
|
23
|
+
/** Atomically derive and persist an org-scoped setting. */
|
|
24
|
+
export async function mutateOrgSetting(orgId, key, updater, options) {
|
|
25
|
+
return mutateSetting(orgKey(orgId, key), updater, options);
|
|
26
|
+
}
|
|
23
27
|
/** Delete an org-scoped setting. */
|
|
24
28
|
export async function deleteOrgSetting(orgId, key, options) {
|
|
25
29
|
return deleteSetting(orgKey(orgId, key), options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"org-settings.js","sourceRoot":"","sources":["../../src/settings/org-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,SAAS,MAAM,CAAC,KAAa,EAAE,GAAW;IACxC,OAAO,KAAK,KAAK,IAAI,GAAG,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,GAAW;IAEX,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,GAAW,EACX,KAA8B,EAC9B,OAA2B;IAE3B,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,oCAAoC;AACpC,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,GAAW,EACX,OAA2B;IAE3B,OAAO,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAa,EACb,SAAkB;IAElB,MAAM,GAAG,GAAG,MAAM,cAAc,EAAE,CAAC;IACnC,MAAM,GAAG,GAA4C,EAAE,CAAC;IACxD,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;YAAE,SAAS;QACnC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,SAAS,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,SAAS;QACtD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Org-scoped settings helpers.\n *\n * Wraps the global settings store with per-org key prefixing.\n * Keys are stored as `o:<orgId>:<key>` in the settings table.\n *\n * No global fallback — each org starts with a clean slate. This\n * prevents one org's data from leaking to another.\n */\n\nimport {\n getSetting,\n putSetting,\n deleteSetting,\n getAllSettings,\n type StoreWriteOptions,\n} from \"./store.js\";\n\nfunction orgKey(orgId: string, key: string): string {\n return `o:${orgId}:${key}`;\n}\n\nconst ORG_PREFIX_RE = /^o:([^:]+):(.+)$/;\n\n/** Read an org-scoped setting. Returns null if not set for this org. */\nexport async function getOrgSetting(\n orgId: string,\n key: string,\n): Promise<Record<string, unknown> | null> {\n return getSetting(orgKey(orgId, key));\n}\n\n/** Write an org-scoped setting. Always writes to the prefixed key. */\nexport async function putOrgSetting(\n orgId: string,\n key: string,\n value: Record<string, unknown>,\n options?: StoreWriteOptions,\n): Promise<void> {\n return putSetting(orgKey(orgId, key), value, options);\n}\n\n/** Delete an org-scoped setting. */\nexport async function deleteOrgSetting(\n orgId: string,\n key: string,\n options?: StoreWriteOptions,\n): Promise<boolean> {\n return deleteSetting(orgKey(orgId, key), options);\n}\n\n/**\n * List all settings keys for an org with an optional sub-prefix.\n * Returns a map of `<key>` (without the org prefix) to value.\n */\nexport async function listOrgSettings(\n orgId: string,\n subPrefix?: string,\n): Promise<Record<string, Record<string, unknown>>> {\n const all = await getAllSettings();\n const out: Record<string, Record<string, unknown>> = {};\n for (const [fullKey, value] of Object.entries(all)) {\n const m = ORG_PREFIX_RE.exec(fullKey);\n if (!m || m[1] !== orgId) continue;\n const key = m[2];\n if (subPrefix && !key.startsWith(subPrefix)) continue;\n out[key] = value;\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"org-settings.js","sourceRoot":"","sources":["../../src/settings/org-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACb,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,SAAS,MAAM,CAAC,KAAa,EAAE,GAAW;IACxC,OAAO,KAAK,KAAK,IAAI,GAAG,EAAE,CAAC;AAC7B,CAAC;A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C,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,SAAS,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,SAAS;QACtD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Org-scoped settings helpers.\n *\n * Wraps the global settings store with per-org key prefixing.\n * Keys are stored as `o:<orgId>:<key>` in the settings table.\n *\n * No global fallback — each org starts with a clean slate. This\n * prevents one org's data from leaking to another.\n */\n\nimport {\n getSetting,\n mutateSetting,\n putSetting,\n deleteSetting,\n getAllSettings,\n type StoreWriteOptions,\n} from \"./store.js\";\n\nfunction orgKey(orgId: string, key: string): string {\n return `o:${orgId}:${key}`;\n}\n\nconst ORG_PREFIX_RE = /^o:([^:]+):(.+)$/;\n\n/** Read an org-scoped setting. Returns null if not set for this org. */\nexport async function getOrgSetting(\n orgId: string,\n key: string,\n): Promise<Record<string, unknown> | null> {\n return getSetting(orgKey(orgId, key));\n}\n\n/** Write an org-scoped setting. Always writes to the prefixed key. */\nexport async function putOrgSetting(\n orgId: string,\n key: string,\n value: Record<string, unknown>,\n options?: StoreWriteOptions,\n): Promise<void> {\n return putSetting(orgKey(orgId, key), value, options);\n}\n\n/** Atomically derive and persist an org-scoped setting. */\nexport async function mutateOrgSetting(\n orgId: string,\n key: string,\n updater: (\n current: Record<string, unknown> | null,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>,\n options?: StoreWriteOptions,\n): Promise<Record<string, unknown>> {\n return mutateSetting(orgKey(orgId, key), updater, options);\n}\n\n/** Delete an org-scoped setting. */\nexport async function deleteOrgSetting(\n orgId: string,\n key: string,\n options?: StoreWriteOptions,\n): Promise<boolean> {\n return deleteSetting(orgKey(orgId, key), options);\n}\n\n/**\n * List all settings keys for an org with an optional sub-prefix.\n * Returns a map of `<key>` (without the org prefix) to value.\n */\nexport async function listOrgSettings(\n orgId: string,\n subPrefix?: string,\n): Promise<Record<string, Record<string, unknown>>> {\n const all = await getAllSettings();\n const out: Record<string, Record<string, unknown>> = {};\n for (const [fullKey, value] of Object.entries(all)) {\n const m = ORG_PREFIX_RE.exec(fullKey);\n if (!m || m[1] !== orgId) continue;\n const key = m[2];\n if (subPrefix && !key.startsWith(subPrefix)) continue;\n out[key] = value;\n }\n return out;\n}\n"]}
|
package/dist/settings/store.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export interface StoreWriteOptions {
|
|
|
5
5
|
/** Tag identifying who initiated this write (e.g. a tab ID). */
|
|
6
6
|
requestSource?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Atomically derive and persist one setting with an optimistic raw-value CAS.
|
|
10
|
+
* This works across SQLite/libSQL and Postgres and remains safe across
|
|
11
|
+
* horizontally scaled processes where an in-memory mutex would not.
|
|
12
|
+
* The updater may run more than once after contention and must not perform
|
|
13
|
+
* external side effects.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mutateSetting(key: string, updater: (current: Record<string, unknown> | null) => Record<string, unknown> | Promise<Record<string, unknown>>, options?: StoreWriteOptions): Promise<Record<string, unknown>>;
|
|
8
16
|
export declare function putSetting(key: string, value: Record<string, unknown>, options?: StoreWriteOptions): Promise<void>;
|
|
9
17
|
export declare function deleteSetting(key: string, options?: StoreWriteOptions): Promise<boolean>;
|
|
10
18
|
export declare function getAllSettings(): Promise<Record<string, Record<string, unknown>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/settings/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAiCtC,wBAAgB,kBAAkB,IAAI,YAAY,CAEjD;AAsED,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAgBzC;AAED,MAAM,WAAW,iBAAi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ACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAmBlB;AAED,wBAAsB,cAAc,IAAI,OAAO,CAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CACxC,CAUA"}
|
package/dist/settings/store.js
CHANGED
|
@@ -106,6 +106,54 @@ export async function getSetting(key) {
|
|
|
106
106
|
cache?.set(key, raw);
|
|
107
107
|
return raw == null ? null : JSON.parse(raw);
|
|
108
108
|
}
|
|
109
|
+
const SETTINGS_MUTATION_ATTEMPTS = 25;
|
|
110
|
+
/**
|
|
111
|
+
* Atomically derive and persist one setting with an optimistic raw-value CAS.
|
|
112
|
+
* This works across SQLite/libSQL and Postgres and remains safe across
|
|
113
|
+
* horizontally scaled processes where an in-memory mutex would not.
|
|
114
|
+
* The updater may run more than once after contention and must not perform
|
|
115
|
+
* external side effects.
|
|
116
|
+
*/
|
|
117
|
+
export async function mutateSetting(key, updater, options) {
|
|
118
|
+
await ensureTable();
|
|
119
|
+
const client = getDbExec();
|
|
120
|
+
const table = settingsTable();
|
|
121
|
+
for (let attempt = 0; attempt < SETTINGS_MUTATION_ATTEMPTS; attempt += 1) {
|
|
122
|
+
// Deliberately bypass the request cache: a failed CAS means another
|
|
123
|
+
// request committed a newer value and the next attempt must reread it.
|
|
124
|
+
const snapshot = await client.execute({
|
|
125
|
+
sql: `SELECT value FROM ${table} WHERE key = ?`,
|
|
126
|
+
args: [key],
|
|
127
|
+
});
|
|
128
|
+
const raw = snapshot.rows.length === 0 ? null : snapshot.rows[0]?.value;
|
|
129
|
+
const current = raw == null ? null : JSON.parse(raw);
|
|
130
|
+
const next = await updater(current);
|
|
131
|
+
const nextRaw = JSON.stringify(next);
|
|
132
|
+
const timestamp = Date.now();
|
|
133
|
+
const result = raw == null
|
|
134
|
+
? await client.execute({
|
|
135
|
+
sql: isPostgres()
|
|
136
|
+
? `INSERT INTO ${table} (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT (key) DO NOTHING`
|
|
137
|
+
: `INSERT OR IGNORE INTO ${table} (key, value, updated_at) VALUES (?, ?, ?)`,
|
|
138
|
+
args: [key, nextRaw, timestamp],
|
|
139
|
+
})
|
|
140
|
+
: await client.execute({
|
|
141
|
+
sql: `UPDATE ${table} SET value = ?, updated_at = ? WHERE key = ? AND value = ?`,
|
|
142
|
+
args: [nextRaw, timestamp, key, raw],
|
|
143
|
+
});
|
|
144
|
+
if (result.rowsAffected === 0)
|
|
145
|
+
continue;
|
|
146
|
+
requestSettingsCache()?.set(key, nextRaw);
|
|
147
|
+
_emitter.emit("settings", {
|
|
148
|
+
source: "settings",
|
|
149
|
+
type: "change",
|
|
150
|
+
key,
|
|
151
|
+
...(options?.requestSource && { requestSource: options.requestSource }),
|
|
152
|
+
});
|
|
153
|
+
return JSON.parse(nextRaw);
|
|
154
|
+
}
|
|
155
|
+
throw new Error(`Setting ${key} changed too many times; retry the mutation.`);
|
|
156
|
+
}
|
|
109
157
|
export async function putSetting(key, value, options) {
|
|
110
158
|
await ensureTable();
|
|
111
159
|
const client = getDbExec();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/settings/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAA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AAC;IACzE,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,GAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { EventEmitter } from \"events\";\n\nimport { getDbExec, isPostgres, intType } from \"../db/client.js\";\nimport { ensureIndexExists, ensureTableExists } from \"../db/ddl-guard.js\";\nimport { widenIntColumnsToBigInt } from \"../db/widen-columns.js\";\nimport { getRequestContext } from \"../server/request-context.js\";\n\nlet _initPromise: Promise<void> | undefined;\n\n// Per-request memoization of settings reads, keyed on the active\n// AsyncLocalStorage RequestContext (WeakMap → freed with the request). One\n// action request can read the same setting several times (org resolution,\n// guards, the action body), and each read is a network round trip on\n// serverless Postgres. Mirrors the per-request session/org caches on\n// event.context. The cache holds the raw JSON string and re-parses per hit\n// so callers can't mutate a shared object; writes in the same request are\n// written through, while other in-flight requests keep their snapshot for\n// their own (short) lifetime.\nconst _requestSettingsCache = new WeakMap<object, Map<string, string | null>>();\n\nfunction requestSettingsCache(): Map<string, string | null> | null {\n const ctx = getRequestContext();\n if (!ctx || typeof ctx !== \"object\") return null;\n let cache = _requestSettingsCache.get(ctx);\n if (!cache) {\n cache = new Map();\n _requestSettingsCache.set(ctx, cache);\n }\n return cache;\n}\n\nconst _emitter = new EventEmitter();\n\nexport function getSettingsEmitter(): EventEmitter {\n return _emitter;\n}\n\nfunction settingsTable(): string {\n return isPostgres() ? \"public.settings\" : \"settings\";\n}\n\nasync function ensureTable(): Promise<void> {\n if (!_initPromise) {\n _initPromise = (async () => {\n const client = getDbExec();\n const table = settingsTable();\n const createSql = `\n CREATE TABLE IF NOT EXISTS ${table} (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n updated_at ${intType()} NOT NULL\n )\n `;\n\n if (isPostgres()) {\n // Hot path: the `settings` table and its poll index are virtually\n // always already present in production. Issuing `CREATE TABLE`/\n // `CREATE INDEX` still takes a lock that, in a fresh background-worker\n // process behind a concurrent connection on the shared Neon DB, can\n // block ~indefinitely (ACCESS EXCLUSIVE for CREATE TABLE; a write-\n // blocking SHARE lock for CREATE INDEX). `ensureTableExists` /\n // `ensureIndexExists` probe `information_schema`/`pg_indexes` first\n // (plain reads, no lock) and run DDL ONLY for what is actually missing,\n // bounding any DDL with a transaction-scoped `lock_timeout`. They also\n // re-probe after a swallowed lock-timeout and THROW if the schema is\n // still missing, so a timed-out DDL never poisons this init memo with\n // missing schema. `settingsTable()` is `public.settings` on Postgres;\n // the existence checks use the unqualified table name.\n await ensureTableExists(\"settings\", createSql);\n // Older deployments (pre BIGINT-compat) have a 32-bit `updated_at`; on\n // Postgres the `Date.now()` written on every setSetting overflows int4.\n // widenIntColumnsToBigInt already probes information_schema and only\n // ALTERs columns that are still int4 — a no-op on fresh/widened DBs.\n await widenIntColumnsToBigInt(\"settings\", [\"updated_at\"]);\n // Index for the poll watermark query: `SELECT MAX(updated_at)`.\n await ensureIndexExists(\n \"settings_updated_at_idx\",\n `CREATE INDEX IF NOT EXISTS settings_updated_at_idx ON ${table} (updated_at)`,\n );\n return;\n }\n\n // SQLite (local dev): no lock problem — keep the original behaviour.\n await client.execute(createSql);\n // No-op on SQLite (INTEGER is already 64-bit).\n await widenIntColumnsToBigInt(\"settings\", [\"updated_at\"]);\n // Index for the poll watermark query: `SELECT MAX(updated_at) FROM settings`.\n // MAX on an indexed column avoids a full-table scan on every poll cycle.\n // IF NOT EXISTS makes it idempotent on existing databases.\n try {\n await client.execute(\n `CREATE INDEX IF NOT EXISTS settings_updated_at_idx ON ${table} (updated_at)`,\n );\n } catch {\n // Index already exists or the dialect rejected a duplicate.\n }\n })().catch((err) => {\n // Retry init on the next call after a failed startup.\n _initPromise = undefined;\n throw err;\n });\n }\n return _initPromise;\n}\n\nexport async function getSetting(\n key: string,\n): Promise<Record<string, unknown> | null> {\n const cache = requestSettingsCache();\n if (cache?.has(key)) {\n const cached = cache.get(key);\n return cached == null ? null : JSON.parse(cached);\n }\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const { rows } = await client.execute({\n sql: `SELECT value FROM ${table} WHERE key = ?`,\n args: [key],\n });\n const raw = rows.length === 0 ? null : (rows[0].value as string);\n cache?.set(key, raw);\n return raw == null ? null : JSON.parse(raw);\n}\n\nexport interface StoreWriteOptions {\n /** Tag identifying who initiated this write (e.g. a tab ID). */\n requestSource?: string;\n}\n\nexport async function putSetting(\n key: string,\n value: Record<string, unknown>,\n options?: StoreWriteOptions,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n await client.execute({\n sql: isPostgres()\n ? `INSERT INTO ${table} (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value=EXCLUDED.value, updated_at=EXCLUDED.updated_at`\n : `INSERT OR REPLACE INTO ${table} (key, value, updated_at) VALUES (?, ?, ?)`,\n args: [key, JSON.stringify(value), Date.now()],\n });\n requestSettingsCache()?.set(key, JSON.stringify(value));\n _emitter.emit(\"settings\", {\n source: \"settings\",\n type: \"change\",\n key,\n ...(options?.requestSource && { requestSource: options.requestSource }),\n });\n}\n\nexport async function deleteSetting(\n key: string,\n options?: StoreWriteOptions,\n): Promise<boolean> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const result = await client.execute({\n sql: `DELETE FROM ${table} WHERE key = ?`,\n args: [key],\n });\n requestSettingsCache()?.set(key, null);\n if (result.rowsAffected > 0) {\n _emitter.emit(\"settings\", {\n source: \"settings\",\n type: \"delete\",\n key,\n ...(options?.requestSource && { requestSource: options.requestSource }),\n });\n return true;\n }\n return false;\n}\n\nexport async function getAllSettings(): Promise<\n Record<string, Record<string, unknown>>\n> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const { rows } = await client.execute(`SELECT key, value FROM ${table}`);\n const result: Record<string, Record<string, unknown>> = {};\n for (const row of rows) {\n result[row.key as string] = JSON.parse(row.value as string);\n }\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/settings/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,IAAI,YAAuC,CAAC;AAE5C,iEAAiE;AACjE,2EAA2E;AAC3E,0EAA0E;AAC1E,qEAAqE;AACrE,qEAAqE;AACrE,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,8BAA8B;AAC9B,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAsC,CAAC;AAEhF,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAG,iBAAiB,EAAE,CAAC;IAChC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjD,IAAI,KAAK,GAAG,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QAClB,qBAAqB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;AAEpC,MAAM,UAAU,kBAAkB;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,UAAU,EAAE,CAAC,CAAC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AAG,CAAC,GAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { EventEmitter } from \"events\";\n\nimport { getDbExec, isPostgres, intType } from \"../db/client.js\";\nimport { ensureIndexExists, ensureTableExists } from \"../db/ddl-guard.js\";\nimport { widenIntColumnsToBigInt } from \"../db/widen-columns.js\";\nimport { getRequestContext } from \"../server/request-context.js\";\n\nlet _initPromise: Promise<void> | undefined;\n\n// Per-request memoization of settings reads, keyed on the active\n// AsyncLocalStorage RequestContext (WeakMap → freed with the request). One\n// action request can read the same setting several times (org resolution,\n// guards, the action body), and each read is a network round trip on\n// serverless Postgres. Mirrors the per-request session/org caches on\n// event.context. The cache holds the raw JSON string and re-parses per hit\n// so callers can't mutate a shared object; writes in the same request are\n// written through, while other in-flight requests keep their snapshot for\n// their own (short) lifetime.\nconst _requestSettingsCache = new WeakMap<object, Map<string, string | null>>();\n\nfunction requestSettingsCache(): Map<string, string | null> | null {\n const ctx = getRequestContext();\n if (!ctx || typeof ctx !== \"object\") return null;\n let cache = _requestSettingsCache.get(ctx);\n if (!cache) {\n cache = new Map();\n _requestSettingsCache.set(ctx, cache);\n }\n return cache;\n}\n\nconst _emitter = new EventEmitter();\n\nexport function getSettingsEmitter(): EventEmitter {\n return _emitter;\n}\n\nfunction settingsTable(): string {\n return isPostgres() ? \"public.settings\" : \"settings\";\n}\n\nasync function ensureTable(): Promise<void> {\n if (!_initPromise) {\n _initPromise = (async () => {\n const client = getDbExec();\n const table = settingsTable();\n const createSql = `\n CREATE TABLE IF NOT EXISTS ${table} (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n updated_at ${intType()} NOT NULL\n )\n `;\n\n if (isPostgres()) {\n // Hot path: the `settings` table and its poll index are virtually\n // always already present in production. Issuing `CREATE TABLE`/\n // `CREATE INDEX` still takes a lock that, in a fresh background-worker\n // process behind a concurrent connection on the shared Neon DB, can\n // block ~indefinitely (ACCESS EXCLUSIVE for CREATE TABLE; a write-\n // blocking SHARE lock for CREATE INDEX). `ensureTableExists` /\n // `ensureIndexExists` probe `information_schema`/`pg_indexes` first\n // (plain reads, no lock) and run DDL ONLY for what is actually missing,\n // bounding any DDL with a transaction-scoped `lock_timeout`. They also\n // re-probe after a swallowed lock-timeout and THROW if the schema is\n // still missing, so a timed-out DDL never poisons this init memo with\n // missing schema. `settingsTable()` is `public.settings` on Postgres;\n // the existence checks use the unqualified table name.\n await ensureTableExists(\"settings\", createSql);\n // Older deployments (pre BIGINT-compat) have a 32-bit `updated_at`; on\n // Postgres the `Date.now()` written on every setSetting overflows int4.\n // widenIntColumnsToBigInt already probes information_schema and only\n // ALTERs columns that are still int4 — a no-op on fresh/widened DBs.\n await widenIntColumnsToBigInt(\"settings\", [\"updated_at\"]);\n // Index for the poll watermark query: `SELECT MAX(updated_at)`.\n await ensureIndexExists(\n \"settings_updated_at_idx\",\n `CREATE INDEX IF NOT EXISTS settings_updated_at_idx ON ${table} (updated_at)`,\n );\n return;\n }\n\n // SQLite (local dev): no lock problem — keep the original behaviour.\n await client.execute(createSql);\n // No-op on SQLite (INTEGER is already 64-bit).\n await widenIntColumnsToBigInt(\"settings\", [\"updated_at\"]);\n // Index for the poll watermark query: `SELECT MAX(updated_at) FROM settings`.\n // MAX on an indexed column avoids a full-table scan on every poll cycle.\n // IF NOT EXISTS makes it idempotent on existing databases.\n try {\n await client.execute(\n `CREATE INDEX IF NOT EXISTS settings_updated_at_idx ON ${table} (updated_at)`,\n );\n } catch {\n // Index already exists or the dialect rejected a duplicate.\n }\n })().catch((err) => {\n // Retry init on the next call after a failed startup.\n _initPromise = undefined;\n throw err;\n });\n }\n return _initPromise;\n}\n\nexport async function getSetting(\n key: string,\n): Promise<Record<string, unknown> | null> {\n const cache = requestSettingsCache();\n if (cache?.has(key)) {\n const cached = cache.get(key);\n return cached == null ? null : JSON.parse(cached);\n }\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const { rows } = await client.execute({\n sql: `SELECT value FROM ${table} WHERE key = ?`,\n args: [key],\n });\n const raw = rows.length === 0 ? null : (rows[0].value as string);\n cache?.set(key, raw);\n return raw == null ? null : JSON.parse(raw);\n}\n\nexport interface StoreWriteOptions {\n /** Tag identifying who initiated this write (e.g. a tab ID). */\n requestSource?: string;\n}\n\nconst SETTINGS_MUTATION_ATTEMPTS = 25;\n\n/**\n * Atomically derive and persist one setting with an optimistic raw-value CAS.\n * This works across SQLite/libSQL and Postgres and remains safe across\n * horizontally scaled processes where an in-memory mutex would not.\n * The updater may run more than once after contention and must not perform\n * external side effects.\n */\nexport async function mutateSetting(\n key: string,\n updater: (\n current: Record<string, unknown> | null,\n ) => Record<string, unknown> | Promise<Record<string, unknown>>,\n options?: StoreWriteOptions,\n): Promise<Record<string, unknown>> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n for (let attempt = 0; attempt < SETTINGS_MUTATION_ATTEMPTS; attempt += 1) {\n // Deliberately bypass the request cache: a failed CAS means another\n // request committed a newer value and the next attempt must reread it.\n const snapshot = await client.execute({\n sql: `SELECT value FROM ${table} WHERE key = ?`,\n args: [key],\n });\n const raw =\n snapshot.rows.length === 0 ? null : (snapshot.rows[0]?.value as string);\n const current = raw == null ? null : JSON.parse(raw);\n const next = await updater(current);\n const nextRaw = JSON.stringify(next);\n const timestamp = Date.now();\n const result =\n raw == null\n ? await client.execute({\n sql: isPostgres()\n ? `INSERT INTO ${table} (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT (key) DO NOTHING`\n : `INSERT OR IGNORE INTO ${table} (key, value, updated_at) VALUES (?, ?, ?)`,\n args: [key, nextRaw, timestamp],\n })\n : await client.execute({\n sql: `UPDATE ${table} SET value = ?, updated_at = ? WHERE key = ? AND value = ?`,\n args: [nextRaw, timestamp, key, raw],\n });\n if (result.rowsAffected === 0) continue;\n requestSettingsCache()?.set(key, nextRaw);\n _emitter.emit(\"settings\", {\n source: \"settings\",\n type: \"change\",\n key,\n ...(options?.requestSource && { requestSource: options.requestSource }),\n });\n return JSON.parse(nextRaw);\n }\n throw new Error(`Setting ${key} changed too many times; retry the mutation.`);\n}\n\nexport async function putSetting(\n key: string,\n value: Record<string, unknown>,\n options?: StoreWriteOptions,\n): Promise<void> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n await client.execute({\n sql: isPostgres()\n ? `INSERT INTO ${table} (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value=EXCLUDED.value, updated_at=EXCLUDED.updated_at`\n : `INSERT OR REPLACE INTO ${table} (key, value, updated_at) VALUES (?, ?, ?)`,\n args: [key, JSON.stringify(value), Date.now()],\n });\n requestSettingsCache()?.set(key, JSON.stringify(value));\n _emitter.emit(\"settings\", {\n source: \"settings\",\n type: \"change\",\n key,\n ...(options?.requestSource && { requestSource: options.requestSource }),\n });\n}\n\nexport async function deleteSetting(\n key: string,\n options?: StoreWriteOptions,\n): Promise<boolean> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const result = await client.execute({\n sql: `DELETE FROM ${table} WHERE key = ?`,\n args: [key],\n });\n requestSettingsCache()?.set(key, null);\n if (result.rowsAffected > 0) {\n _emitter.emit(\"settings\", {\n source: \"settings\",\n type: \"delete\",\n key,\n ...(options?.requestSource && { requestSource: options.requestSource }),\n });\n return true;\n }\n return false;\n}\n\nexport async function getAllSettings(): Promise<\n Record<string, Record<string, unknown>>\n> {\n await ensureTable();\n const client = getDbExec();\n const table = settingsTable();\n const { rows } = await client.execute(`SELECT key, value FROM ${table}`);\n const result: Record<string, Record<string, unknown>> = {};\n for (const row of rows) {\n result[row.key as string] = JSON.parse(row.value as string);\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feature-flags
|
|
3
|
+
description: >-
|
|
4
|
+
Declare, evaluate, manage, and remove framework feature flags. Use when
|
|
5
|
+
shipping a capability gradually, targeting users or organizations, or
|
|
6
|
+
replacing a compile-time rollout switch with a production-safe runtime flag.
|
|
7
|
+
scope: dev
|
|
8
|
+
metadata:
|
|
9
|
+
internal: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Feature Flags
|
|
13
|
+
|
|
14
|
+
A feature flag is a boolean declared in app code, evaluated locally by Core,
|
|
15
|
+
and managed from the Analytics fleet control plane. Code owns whether a flag
|
|
16
|
+
exists. Runtime settings own only its rollout state.
|
|
17
|
+
|
|
18
|
+
Flags let an app deploy dormant code and turn it on in the real environment
|
|
19
|
+
without another deployment. They are not experiments: do not add variants,
|
|
20
|
+
hypotheses, conversion metrics, exposure tracking, or lifecycle states.
|
|
21
|
+
|
|
22
|
+
## When to use one
|
|
23
|
+
|
|
24
|
+
Use a flag for a reversible rollout of a user-facing capability whose dormant
|
|
25
|
+
code is safe to deploy. Flags are useful for production dogfooding, exact-user
|
|
26
|
+
or organization pilots, and deterministic percentage rollouts.
|
|
27
|
+
|
|
28
|
+
Do not use a flag for authentication, authorization, secrets, audit enablement,
|
|
29
|
+
SSR cache behavior, or another security boundary. Client hiding is presentation
|
|
30
|
+
only; every guarded server action must evaluate the same registered flag.
|
|
31
|
+
|
|
32
|
+
## Agent workflow
|
|
33
|
+
|
|
34
|
+
### 1. Declare
|
|
35
|
+
|
|
36
|
+
Keep definitions in a shared TypeScript module so server and client code use the
|
|
37
|
+
same stable key. Flags are boolean and default-off.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags";
|
|
41
|
+
|
|
42
|
+
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
|
+
key: "full-app-building",
|
|
44
|
+
displayName: "Full app building",
|
|
45
|
+
description: "Create and edit Fusion-backed applications.",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Keys are immutable, never reused, and contain only letters, numbers, dots,
|
|
50
|
+
underscores, or hyphens. Prefer a concise app-owned name. Do not create flag
|
|
51
|
+
definitions or rollout rows from Analytics.
|
|
52
|
+
|
|
53
|
+
### 2. Register
|
|
54
|
+
|
|
55
|
+
Register app definitions from a Nitro plugin before actions are discovered.
|
|
56
|
+
Do not add app-specific flags to a Core registry.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { createFeatureFlagsPlugin } from "@agent-native/core/server";
|
|
60
|
+
|
|
61
|
+
import { FULL_APP_BUILDING } from "../../shared/feature-flags.js";
|
|
62
|
+
|
|
63
|
+
export default createFeatureFlagsPlugin({ flags: [FULL_APP_BUILDING] });
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Guard server and client
|
|
67
|
+
|
|
68
|
+
The server action is the enforcement boundary:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
|
|
72
|
+
|
|
73
|
+
run: async (args, ctx) => {
|
|
74
|
+
if (!(await isFeatureFlagEnabled(FULL_APP_BUILDING, ctx))) {
|
|
75
|
+
throw new Error("Full app building is not enabled for this account.");
|
|
76
|
+
}
|
|
77
|
+
// guarded operation
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use the client hook only to hide or reveal hydrated UI:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useFeatureFlag } from "@agent-native/core/client";
|
|
85
|
+
|
|
86
|
+
const enabled = useFeatureFlag(FULL_APP_BUILDING.key);
|
|
87
|
+
return enabled ? <FullAppOption /> : null;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The client hook intentionally returns false while loading or for an unknown
|
|
91
|
+
flag. Never replace that fail-closed behavior with app-local bucketing or a
|
|
92
|
+
compile-time fallback. Never evaluate personalized flags in the public SSR
|
|
93
|
+
shell; it is shared and cached for every visitor.
|
|
94
|
+
|
|
95
|
+
### 4. Verify and roll out
|
|
96
|
+
|
|
97
|
+
1. Verify the off path before changing rollout state.
|
|
98
|
+
2. Confirm the registered flag appears in **Analytics → Feature flags** for the
|
|
99
|
+
app and is Off by default.
|
|
100
|
+
3. Use **Enable for me** for initial production dogfood.
|
|
101
|
+
4. Expand to exact emails, organization IDs, or a percentage only from
|
|
102
|
+
Analytics.
|
|
103
|
+
5. Confirm the client presentation and authoritative server action agree.
|
|
104
|
+
|
|
105
|
+
## Management contract
|
|
106
|
+
|
|
107
|
+
Core mounts three actions in registered apps:
|
|
108
|
+
|
|
109
|
+
| Action | Purpose |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `get-feature-flags` | Return the current caller's evaluated boolean values. |
|
|
112
|
+
| `list-feature-flags` | Return definitions and rollout metadata to an authorized operator. |
|
|
113
|
+
| `set-feature-flag` | Atomically turn a flag off, enable it for the operator, or replace targeting rules. |
|
|
114
|
+
|
|
115
|
+
Analytics calls the app-local operator actions through narrowly scoped A2A
|
|
116
|
+
delegation. Tokens require an exact audience, organization, scope, operator
|
|
117
|
+
role, and audit correlation id. Management is permission-checked and audited
|
|
118
|
+
by the target app. Never manage flags through generic settings routes, raw SQL,
|
|
119
|
+
or per-app toggle UIs.
|
|
120
|
+
|
|
121
|
+
## Rollout semantics
|
|
122
|
+
|
|
123
|
+
The operator modes are **Off**, **Targeted**, and **Everyone**. Core stores them
|
|
124
|
+
as `off`, `rules`, and `on`.
|
|
125
|
+
|
|
126
|
+
Targeted rules combine exact normalized emails, exact organization IDs, and a
|
|
127
|
+
percentage with OR semantics. Exact matches are checked first. Percentage
|
|
128
|
+
buckets use Core's stable hash of the flag key and authenticated user identity;
|
|
129
|
+
anonymous callers fail closed. Raising a percentage preserves the users already
|
|
130
|
+
included at a lower percentage. Do not implement bucketing in app code.
|
|
131
|
+
|
|
132
|
+
Unknown definitions, missing state, malformed state, storage errors, and
|
|
133
|
+
evaluation errors all return the code default (`false` in v1). Explicit Off
|
|
134
|
+
wins over every target; Everyone enables every authenticated caller.
|
|
135
|
+
|
|
136
|
+
## Remove a flag
|
|
137
|
+
|
|
138
|
+
After a rollout is permanent:
|
|
139
|
+
|
|
140
|
+
1. Replace guarded branches with the chosen behavior.
|
|
141
|
+
2. Delete the server and client gates.
|
|
142
|
+
3. Delete the definition and registration entry.
|
|
143
|
+
4. Verify the flag disappears from the Analytics fleet.
|
|
144
|
+
5. Remove stale tests and rollout instructions.
|
|
145
|
+
|
|
146
|
+
A permanent flag is just an if statement with a pension plan.
|
|
147
|
+
|
|
148
|
+
## Verification checklist
|
|
149
|
+
|
|
150
|
+
- Unknown and unregistered keys evaluate false.
|
|
151
|
+
- UI hiding and server enforcement use the same registered key.
|
|
152
|
+
- Exact-user, organization, deterministic percentage, Everyone, and Off paths
|
|
153
|
+
have focused tests.
|
|
154
|
+
- Increasing a percentage is monotonic; anonymous percentage evaluation is off.
|
|
155
|
+
- Unauthorized callers cannot list targeting details or mutate flags.
|
|
156
|
+
- Mutations are atomic, read back stored state, emit refresh, and appear in the
|
|
157
|
+
audit log with the flag key.
|
|
158
|
+
- Analytics represents ready, no-definition, unsupported, forbidden, legacy,
|
|
159
|
+
and unreachable directory apps honestly.
|
|
160
|
+
- Future agents can find this skill from root `AGENTS.md`, and
|
|
161
|
+
`pnpm guard:workspace-skills` passes after syncing generated copies.
|
|
162
|
+
|
|
163
|
+
## Related skills
|
|
164
|
+
|
|
165
|
+
- **adding-a-feature** — preserve UI/action/instruction/application-state parity
|
|
166
|
+
- **actions** — define and call guarded app operations
|
|
167
|
+
- **audit-log** — inspect automatic action mutation history
|
|
168
|
+
- **reliable-mutations** — make rollout changes atomic and provable
|
|
169
|
+
- **security** — keep security controls out of feature flags
|