@agent-native/core 0.75.4 → 0.76.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 +47 -0
- package/corpus/core/docs/AGENTS.md +1 -0
- package/corpus/core/docs/content/client.md +15 -0
- package/corpus/core/docs/content/internationalization.md +145 -0
- package/corpus/core/docs/content/locales/ar-SA/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/de-DE/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/es-ES/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/fr-FR/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/hi-IN/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/ja-JP/internationalization.md +114 -0
- package/corpus/core/docs/content/locales/ko-KR/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/pt-BR/internationalization.md +102 -0
- package/corpus/core/docs/content/locales/zh-CN/internationalization.md +102 -0
- package/corpus/core/docs/content/skills-guide.md +19 -18
- package/corpus/core/package.json +7 -1
- package/corpus/core/src/agent/durable-background.ts +62 -28
- package/corpus/core/src/agent/production-agent.ts +16 -12
- package/corpus/core/src/cli/skills.ts +22 -4
- package/corpus/core/src/client/CommandMenu.tsx +16 -0
- package/corpus/core/src/client/app-providers.tsx +26 -1
- package/corpus/core/src/client/i18n.tsx +605 -0
- package/corpus/core/src/client/index.ts +28 -0
- package/corpus/core/src/deploy/build.ts +47 -113
- package/corpus/core/src/deploy/workspace-deploy.ts +62 -30
- package/corpus/core/src/index.browser.ts +25 -0
- package/corpus/core/src/localization/actions/get-localization-preference.ts +23 -0
- package/corpus/core/src/localization/actions/set-localization-preference.ts +30 -0
- package/corpus/core/src/localization/index.ts +2 -0
- package/corpus/core/src/localization/server.ts +131 -0
- package/corpus/core/src/localization/shared.ts +163 -0
- package/corpus/core/src/server/action-discovery.ts +8 -0
- package/corpus/core/src/server/index.ts +8 -0
- package/corpus/core/src/server/self-dispatch.ts +29 -2
- package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/core/src/templates/default/.agents/skills/internationalization/SKILL.md +77 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/core/src/templates/default/AGENTS.md +16 -15
- package/corpus/core/src/templates/default/app/i18n/en-US.ts +29 -0
- package/corpus/core/src/templates/default/app/i18n/index.ts +13 -0
- package/corpus/core/src/templates/default/app/root.tsx +20 -1
- package/corpus/core/src/templates/default/app/routes/_index.tsx +24 -9
- package/corpus/core/src/templates/default/app/routes/settings.tsx +67 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/internationalization/SKILL.md +77 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/core/src/vite/action-types-plugin.ts +10 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/analytics/app/components/layout/Header.tsx +18 -15
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +7 -5
- package/corpus/templates/analytics/app/components/layout/MobileNav.tsx +9 -3
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +5 -3
- package/corpus/templates/analytics/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/analytics/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/analytics/app/i18n/en-US.ts +3 -0
- package/corpus/templates/analytics/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/analytics/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/analytics/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/analytics/app/i18n/index.ts +31 -0
- package/corpus/templates/analytics/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/analytics/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/analytics/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/analytics/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/analytics/app/i18n-data.ts +433 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +50 -16
- package/corpus/templates/analytics/app/root.tsx +14 -1
- package/corpus/templates/analytics/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/assets/app/components/layout/Header.tsx +17 -8
- package/corpus/templates/assets/app/components/layout/Layout.tsx +10 -6
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +40 -23
- package/corpus/templates/assets/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/assets/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/assets/app/i18n/en-US.ts +3 -0
- package/corpus/templates/assets/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/assets/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/assets/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/assets/app/i18n/index.ts +31 -0
- package/corpus/templates/assets/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/assets/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/assets/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/assets/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/assets/app/i18n-data.ts +668 -0
- package/corpus/templates/assets/app/root.tsx +40 -15
- package/corpus/templates/assets/app/routes/_index.tsx +9 -10
- package/corpus/templates/assets/app/routes/settings.tsx +37 -6
- package/corpus/templates/assets/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/assets/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +12 -8
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +23 -12
- package/corpus/templates/brain/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/brain/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/brain/app/i18n/en-US.ts +3 -0
- package/corpus/templates/brain/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/brain/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/brain/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/brain/app/i18n/index.ts +31 -0
- package/corpus/templates/brain/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/brain/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/brain/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/brain/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/brain/app/i18n-data.ts +624 -0
- package/corpus/templates/brain/app/root.tsx +27 -12
- package/corpus/templates/brain/app/routes/settings.tsx +45 -8
- package/corpus/templates/brain/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/brain/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +2 -0
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +16 -9
- package/corpus/templates/calendar/app/i18n/ar-SA.ts +57 -0
- package/corpus/templates/calendar/app/i18n/de-DE.ts +58 -0
- package/corpus/templates/calendar/app/i18n/en-US.ts +57 -0
- package/corpus/templates/calendar/app/i18n/es-ES.ts +58 -0
- package/corpus/templates/calendar/app/i18n/fr-FR.ts +58 -0
- package/corpus/templates/calendar/app/i18n/hi-IN.ts +57 -0
- package/corpus/templates/calendar/app/i18n/index.ts +31 -0
- package/corpus/templates/calendar/app/i18n/ja-JP.ts +58 -0
- package/corpus/templates/calendar/app/i18n/ko-KR.ts +57 -0
- package/corpus/templates/calendar/app/i18n/pt-BR.ts +57 -0
- package/corpus/templates/calendar/app/i18n/zh-CN.ts +57 -0
- package/corpus/templates/calendar/app/i18n-data.ts +516 -0
- package/corpus/templates/calendar/app/pages/CalendarView.tsx +2 -0
- package/corpus/templates/calendar/app/pages/Settings.tsx +63 -28
- package/corpus/templates/calendar/app/root.tsx +78 -7
- package/corpus/templates/calendar/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/calendar/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/chat/app/components/layout/Header.tsx +17 -11
- package/corpus/templates/chat/app/components/layout/Layout.tsx +12 -8
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +47 -18
- package/corpus/templates/chat/app/i18n/ar-SA.ts +62 -0
- package/corpus/templates/chat/app/i18n/de-DE.ts +63 -0
- package/corpus/templates/chat/app/i18n/en-US.ts +63 -0
- package/corpus/templates/chat/app/i18n/es-ES.ts +63 -0
- package/corpus/templates/chat/app/i18n/fr-FR.ts +63 -0
- package/corpus/templates/chat/app/i18n/hi-IN.ts +63 -0
- package/corpus/templates/chat/app/i18n/index.ts +31 -0
- package/corpus/templates/chat/app/i18n/ja-JP.ts +63 -0
- package/corpus/templates/chat/app/i18n/ko-KR.ts +63 -0
- package/corpus/templates/chat/app/i18n/pt-BR.ts +63 -0
- package/corpus/templates/chat/app/i18n/zh-CN.ts +61 -0
- package/corpus/templates/chat/app/i18n-data.ts +475 -0
- package/corpus/templates/chat/app/root.tsx +18 -5
- package/corpus/templates/chat/app/routes/_index.tsx +9 -8
- package/corpus/templates/chat/app/routes/settings.tsx +86 -0
- package/corpus/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/clips/app/components/layout/Header.tsx +23 -17
- package/corpus/templates/clips/app/components/library/empty-state.tsx +10 -34
- package/corpus/templates/clips/app/components/library/library-layout.tsx +45 -34
- package/corpus/templates/clips/app/i18n/ar-SA.ts +182 -0
- package/corpus/templates/clips/app/i18n/de-DE.ts +184 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +179 -0
- package/corpus/templates/clips/app/i18n/es-ES.ts +183 -0
- package/corpus/templates/clips/app/i18n/fr-FR.ts +184 -0
- package/corpus/templates/clips/app/i18n/hi-IN.ts +180 -0
- package/corpus/templates/clips/app/i18n/index.ts +41 -0
- package/corpus/templates/clips/app/i18n/ja-JP.ts +180 -0
- package/corpus/templates/clips/app/i18n/ko-KR.ts +178 -0
- package/corpus/templates/clips/app/i18n/pt-BR.ts +183 -0
- package/corpus/templates/clips/app/i18n/zh-CN.ts +173 -0
- package/corpus/templates/clips/app/root.tsx +104 -10
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +154 -95
- package/corpus/templates/clips/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-24-chrome-extension-setup-now-shows-a-clear-all-done-confirmati.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-24-clips-now-includes-a-language-picker-and-simplified-chinese-ui.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/permission.html +60 -0
- package/corpus/templates/clips/chrome-extension/src/permission.ts +28 -15
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/content/app/components/EmptyState.tsx +7 -5
- package/corpus/templates/content/app/components/ThemeToggle.tsx +4 -2
- package/corpus/templates/content/app/components/layout/Header.tsx +2 -0
- package/corpus/templates/content/app/components/layout/Layout.tsx +8 -7
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +41 -1
- package/corpus/templates/content/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/content/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/content/app/i18n/en-US.ts +3 -0
- package/corpus/templates/content/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/content/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/content/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/content/app/i18n/index.ts +31 -0
- package/corpus/templates/content/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/content/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/content/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/content/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/content/app/i18n-data.ts +490 -0
- package/corpus/templates/content/app/root.tsx +110 -23
- package/corpus/templates/content/app/routes/_app.settings.tsx +84 -0
- package/corpus/templates/content/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/content/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/design/app/components/layout/Header.tsx +16 -8
- package/corpus/templates/design/app/components/layout/Layout.tsx +8 -6
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +25 -9
- package/corpus/templates/design/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/design/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/design/app/i18n/en-US.ts +3 -0
- package/corpus/templates/design/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/design/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/design/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/design/app/i18n/index.ts +31 -0
- package/corpus/templates/design/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/design/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/design/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/design/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/design/app/i18n-data.ts +350 -0
- package/corpus/templates/design/app/root.tsx +40 -15
- package/corpus/templates/design/app/routes/settings.tsx +43 -0
- package/corpus/templates/design/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/design/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/dispatch/app/i18n/ar-SA.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/de-DE.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/en-US.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/es-ES.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/fr-FR.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/hi-IN.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/index.ts +31 -0
- package/corpus/templates/dispatch/app/i18n/ja-JP.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/ko-KR.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/pt-BR.ts +3 -0
- package/corpus/templates/dispatch/app/i18n/zh-CN.ts +3 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +267 -0
- package/corpus/templates/dispatch/app/root.tsx +18 -4
- package/corpus/templates/dispatch/app/routes/settings.tsx +86 -0
- package/corpus/templates/dispatch/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/forms/app/components/layout/Header.tsx +16 -9
- package/corpus/templates/forms/app/components/layout/Layout.tsx +6 -4
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +34 -17
- package/corpus/templates/forms/app/i18n/ar-SA.ts +58 -0
- package/corpus/templates/forms/app/i18n/de-DE.ts +59 -0
- package/corpus/templates/forms/app/i18n/en-US.ts +59 -0
- package/corpus/templates/forms/app/i18n/es-ES.ts +59 -0
- package/corpus/templates/forms/app/i18n/fr-FR.ts +59 -0
- package/corpus/templates/forms/app/i18n/hi-IN.ts +59 -0
- package/corpus/templates/forms/app/i18n/index.ts +31 -0
- package/corpus/templates/forms/app/i18n/ja-JP.ts +59 -0
- package/corpus/templates/forms/app/i18n/ko-KR.ts +59 -0
- package/corpus/templates/forms/app/i18n/pt-BR.ts +59 -0
- package/corpus/templates/forms/app/i18n/zh-CN.ts +56 -0
- package/corpus/templates/forms/app/root.tsx +65 -16
- package/corpus/templates/forms/app/routes/_app.settings.tsx +85 -0
- package/corpus/templates/forms/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/forms/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +29 -17
- package/corpus/templates/macros/app/components/layout/Header.tsx +16 -10
- package/corpus/templates/macros/app/i18n/ar-SA.ts +54 -0
- package/corpus/templates/macros/app/i18n/de-DE.ts +55 -0
- package/corpus/templates/macros/app/i18n/en-US.ts +55 -0
- package/corpus/templates/macros/app/i18n/es-ES.ts +55 -0
- package/corpus/templates/macros/app/i18n/fr-FR.ts +55 -0
- package/corpus/templates/macros/app/i18n/hi-IN.ts +55 -0
- package/corpus/templates/macros/app/i18n/index.ts +31 -0
- package/corpus/templates/macros/app/i18n/ja-JP.ts +55 -0
- package/corpus/templates/macros/app/i18n/ko-KR.ts +55 -0
- package/corpus/templates/macros/app/i18n/pt-BR.ts +55 -0
- package/corpus/templates/macros/app/i18n/zh-CN.ts +53 -0
- package/corpus/templates/macros/app/root.tsx +65 -15
- package/corpus/templates/macros/app/routes/settings.tsx +85 -0
- package/corpus/templates/macros/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/macros/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +9 -4
- package/corpus/templates/mail/app/i18n/ar-SA.ts +33 -0
- package/corpus/templates/mail/app/i18n/de-DE.ts +33 -0
- package/corpus/templates/mail/app/i18n/en-US.ts +32 -0
- package/corpus/templates/mail/app/i18n/es-ES.ts +33 -0
- package/corpus/templates/mail/app/i18n/fr-FR.ts +33 -0
- package/corpus/templates/mail/app/i18n/hi-IN.ts +32 -0
- package/corpus/templates/mail/app/i18n/index.ts +31 -0
- package/corpus/templates/mail/app/i18n/ja-JP.ts +32 -0
- package/corpus/templates/mail/app/i18n/ko-KR.ts +33 -0
- package/corpus/templates/mail/app/i18n/pt-BR.ts +34 -0
- package/corpus/templates/mail/app/i18n/zh-CN.ts +32 -0
- package/corpus/templates/mail/app/pages/SettingsPage.tsx +67 -13
- package/corpus/templates/mail/app/root.tsx +20 -0
- package/corpus/templates/mail/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/mail/changelog/2026-06-24-settings-now-link-directly-to-agent-settings-for-model-api-k.md +6 -0
- package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/plan/.agents/skills/visual-plan/references/wireframe.md +22 -4
- package/corpus/templates/plan/.agents/skills/visual-recap/references/wireframe.md +22 -4
- package/corpus/templates/plan/app/components/layout/Header.tsx +19 -12
- package/corpus/templates/plan/app/components/layout/Layout.tsx +11 -7
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +41 -28
- package/corpus/templates/plan/app/i18n/ar-SA.ts +77 -0
- package/corpus/templates/plan/app/i18n/de-DE.ts +78 -0
- package/corpus/templates/plan/app/i18n/en-US.ts +78 -0
- package/corpus/templates/plan/app/i18n/es-ES.ts +78 -0
- package/corpus/templates/plan/app/i18n/fr-FR.ts +78 -0
- package/corpus/templates/plan/app/i18n/hi-IN.ts +78 -0
- package/corpus/templates/plan/app/i18n/index.ts +31 -0
- package/corpus/templates/plan/app/i18n/ja-JP.ts +79 -0
- package/corpus/templates/plan/app/i18n/ko-KR.ts +77 -0
- package/corpus/templates/plan/app/i18n/pt-BR.ts +78 -0
- package/corpus/templates/plan/app/i18n/zh-CN.ts +74 -0
- package/corpus/templates/plan/app/root.tsx +45 -8
- package/corpus/templates/plan/app/routes/settings.tsx +86 -0
- package/corpus/templates/plan/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/slides/app/components/layout/Header.tsx +23 -11
- package/corpus/templates/slides/app/components/layout/Layout.tsx +7 -6
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +23 -11
- package/corpus/templates/slides/app/i18n/ar-SA.ts +54 -0
- package/corpus/templates/slides/app/i18n/de-DE.ts +56 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +55 -0
- package/corpus/templates/slides/app/i18n/es-ES.ts +55 -0
- package/corpus/templates/slides/app/i18n/fr-FR.ts +55 -0
- package/corpus/templates/slides/app/i18n/hi-IN.ts +55 -0
- package/corpus/templates/slides/app/i18n/index.ts +31 -0
- package/corpus/templates/slides/app/i18n/ja-JP.ts +55 -0
- package/corpus/templates/slides/app/i18n/ko-KR.ts +55 -0
- package/corpus/templates/slides/app/i18n/pt-BR.ts +55 -0
- package/corpus/templates/slides/app/i18n/zh-CN.ts +53 -0
- package/corpus/templates/slides/app/root.tsx +50 -8
- package/corpus/templates/slides/app/routes/settings.tsx +85 -0
- package/corpus/templates/slides/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/slides/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/templates/videos/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/corpus/templates/videos/app/components/NewCompositionPopover.tsx +14 -9
- package/corpus/templates/videos/app/components/Sidebar.tsx +16 -9
- package/corpus/templates/videos/app/components/StudioHeader.tsx +12 -8
- package/corpus/templates/videos/app/components/layout/Header.tsx +21 -15
- package/corpus/templates/videos/app/components/layout/Layout.tsx +10 -7
- package/corpus/templates/videos/app/components/layout/NavSidebar.tsx +21 -6
- package/corpus/templates/videos/app/i18n/ar-SA.ts +73 -0
- package/corpus/templates/videos/app/i18n/de-DE.ts +75 -0
- package/corpus/templates/videos/app/i18n/en-US.ts +74 -0
- package/corpus/templates/videos/app/i18n/es-ES.ts +75 -0
- package/corpus/templates/videos/app/i18n/fr-FR.ts +75 -0
- package/corpus/templates/videos/app/i18n/hi-IN.ts +74 -0
- package/corpus/templates/videos/app/i18n/index.ts +31 -0
- package/corpus/templates/videos/app/i18n/ja-JP.ts +74 -0
- package/corpus/templates/videos/app/i18n/ko-KR.ts +74 -0
- package/corpus/templates/videos/app/i18n/pt-BR.ts +75 -0
- package/corpus/templates/videos/app/i18n/zh-CN.ts +72 -0
- package/corpus/templates/videos/app/pages/Index.tsx +11 -9
- package/corpus/templates/videos/app/root.tsx +45 -7
- package/corpus/templates/videos/app/routes/settings.tsx +85 -0
- package/corpus/templates/videos/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/templates/videos/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/dist/agent/durable-background.d.ts +32 -28
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +59 -28
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +16 -12
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/skills.d.ts +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +22 -4
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/CommandMenu.d.ts +3 -0
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +9 -0
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/app-providers.d.ts +8 -1
- package/dist/client/app-providers.d.ts.map +1 -1
- package/dist/client/app-providers.js +7 -5
- package/dist/client/app-providers.js.map +1 -1
- package/dist/client/i18n.d.ts +54 -0
- package/dist/client/i18n.d.ts.map +1 -0
- package/dist/client/i18n.js +354 -0
- package/dist/client/i18n.js.map +1 -0
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -1
- package/dist/client/index.js.map +1 -1
- package/dist/deploy/build.d.ts +32 -36
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +47 -104
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/workspace-deploy.js +62 -30
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/localization/actions/get-localization-preference.d.ts +4 -0
- package/dist/localization/actions/get-localization-preference.d.ts.map +1 -0
- package/dist/localization/actions/get-localization-preference.js +16 -0
- package/dist/localization/actions/get-localization-preference.js.map +1 -0
- package/dist/localization/actions/set-localization-preference.d.ts +6 -0
- package/dist/localization/actions/set-localization-preference.d.ts.map +1 -0
- package/dist/localization/actions/set-localization-preference.js +24 -0
- package/dist/localization/actions/set-localization-preference.js.map +1 -0
- package/dist/localization/index.d.ts +3 -0
- package/dist/localization/index.d.ts.map +1 -0
- package/dist/localization/index.js +3 -0
- package/dist/localization/index.js.map +1 -0
- package/dist/localization/server.d.ts +25 -0
- package/dist/localization/server.d.ts.map +1 -0
- package/dist/localization/server.js +69 -0
- package/dist/localization/server.js.map +1 -0
- package/dist/localization/shared.d.ts +25 -0
- package/dist/localization/shared.d.ts.map +1 -0
- package/dist/localization/shared.js +134 -0
- package/dist/localization/shared.js.map +1 -0
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +8 -0
- package/dist/server/action-discovery.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/server/self-dispatch.d.ts +0 -10
- package/dist/server/self-dispatch.d.ts.map +1 -1
- package/dist/server/self-dispatch.js +27 -2
- package/dist/server/self-dispatch.js.map +1 -1
- package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/dist/templates/default/.agents/skills/internationalization/SKILL.md +77 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/dist/templates/default/AGENTS.md +16 -15
- package/dist/templates/default/app/i18n/en-US.ts +29 -0
- package/dist/templates/default/app/i18n/index.ts +13 -0
- package/dist/templates/default/app/root.tsx +20 -1
- package/dist/templates/default/app/routes/_index.tsx +24 -9
- package/dist/templates/default/app/routes/settings.tsx +67 -0
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/internationalization/SKILL.md +77 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +8 -0
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/docs/AGENTS.md +1 -0
- package/docs/content/client.md +15 -0
- package/docs/content/internationalization.md +145 -0
- package/docs/content/locales/ar-SA/internationalization.md +102 -0
- package/docs/content/locales/de-DE/internationalization.md +102 -0
- package/docs/content/locales/es-ES/internationalization.md +102 -0
- package/docs/content/locales/fr-FR/internationalization.md +102 -0
- package/docs/content/locales/hi-IN/internationalization.md +102 -0
- package/docs/content/locales/ja-JP/internationalization.md +114 -0
- package/docs/content/locales/ko-KR/internationalization.md +102 -0
- package/docs/content/locales/pt-BR/internationalization.md +102 -0
- package/docs/content/locales/zh-CN/internationalization.md +102 -0
- package/docs/content/skills-guide.md +19 -18
- package/package.json +7 -1
- package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/src/templates/default/.agents/skills/internationalization/SKILL.md +77 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +6 -0
- package/src/templates/default/AGENTS.md +16 -15
- package/src/templates/default/app/i18n/en-US.ts +29 -0
- package/src/templates/default/app/i18n/index.ts +13 -0
- package/src/templates/default/app/root.tsx +20 -1
- package/src/templates/default/app/routes/_index.tsx +24 -9
- package/src/templates/default/app/routes/settings.tsx +67 -0
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/internationalization/SKILL.md +77 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,SAAS;AACT,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,oCAAoC,EACpC,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,uCAAuC,EACvC,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,UAAU,EACV,EAAE,EACF,cAAc,
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,SAAS;AACT,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,oCAAoC,EACpC,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,uCAAuC,EACvC,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,+BAA+B,EAC/B,2BAA2B,EAC3B,2BAA2B,EAC3B,aAAa,EACb,SAAS,EACT,IAAI,EACJ,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,UAAU,EACV,EAAE,EACF,cAAc,GA2Bf,MAAM,mBAAmB,CAAC;AAE3B,sBAAsB;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,8DAA8D;AAC9D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEnE,2DAA2D;AAC3D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAGtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,GAEpC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAe1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,GAKX,MAAM,sBAAsB,CAAC","sourcesContent":["// Browser-safe entry — only client & shared exports (no Node/Express/chokidar).\n\n// Client\nexport {\n addContextToAgentChat,\n appendAgentChatContextToMessage,\n clearAgentChatContext,\n formatAgentChatContextItemsForPrompt,\n listAgentChatContext,\n refreshAgentChatContext,\n removeAgentChatContextItem,\n sendToAgentChat,\n setAgentChatContextItem,\n setContextToAgentChat,\n isEmbedMcpChatBridgeActive,\n useAgentChatContext,\n useAgentChatGenerating,\n useDevMode,\n useSendToAgentChat,\n AGENT_NATIVE_MCP_APP_HOST_MESSAGE_TYPES,\n getMcpAppHostContext,\n openMcpAppHostLink,\n requestMcpAppDisplayMode,\n sendMcpAppHostMessage,\n updateMcpAppModelContext,\n useMcpAppHostContext,\n CodeRequiredDialog,\n AgentNativeI18nProvider,\n LanguagePicker,\n getLocaleInitScript,\n localeDirection,\n normalizeLocaleCode,\n normalizeLocalePreference,\n normalizeLocalizationPreference,\n resolveLocaleFromCandidates,\n resolveLocaleFromPreference,\n useFormatters,\n useLocale,\n useT,\n DEFAULT_LOCALE,\n LOCALE_HYDRATION_GLOBAL,\n LOCALE_METADATA,\n LOCALE_STORAGE_KEY,\n SUPPORTED_LOCALES,\n useDbSync,\n useFileWatcher,\n useSession,\n cn,\n ApiKeySettings,\n type AgentChatContextItem,\n type AgentChatContextMessage,\n type AgentChatContextMutationOptions,\n type AgentChatContextRemoveOptions,\n type AgentChatContextSetOptions,\n type AgentChatContextState,\n type AgentChatMessage,\n type AgentNativeMcpAppHostMessageType,\n type McpAppDisplayMode,\n type McpAppHostChatMessage,\n type McpAppHostCapabilities,\n type McpAppHostContext,\n type McpAppHostContextSnapshot,\n type McpAppModelContextContentPart,\n type McpAppModelContextUpdate,\n type CodeRequiredDialogProps,\n type AuthSession,\n type UseAgentChatContextResult,\n type AgentNativeI18nCatalog,\n type AgentNativeI18nProviderProps,\n type LocaleCode,\n type LocaleHydrationPayload,\n type LocaleMessages,\n type LocaleMetadata,\n type LocalePreference,\n type LocalizationPreference,\n} from \"./client/index.js\";\n\n// Shared (isomorphic)\nexport { agentChat } from \"./shared/index.js\";\n\n// Pure utilities (no Node.js deps — safe for browser and SSR)\nexport { parseArgs, camelCaseArgs } from \"./scripts/parse-args.js\";\n\n// defineAction — used by template actions, no Node.js deps\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-localization-preference.d.ts","sourceRoot":"","sources":["../../../src/localization/actions/get-localization-preference.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;;AAEtB,wBAaG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../action.js";
|
|
3
|
+
import { getUserSetting } from "../../settings/user-settings.js";
|
|
4
|
+
import { LOCALIZATION_SETTING_KEY, normalizeLocalizationPreference, } from "../shared.js";
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description: "Get the current user's interface language preference. Returns { locale }, where locale is 'system' or a supported BCP-47 locale.",
|
|
7
|
+
schema: z.object({}),
|
|
8
|
+
http: { method: "GET" },
|
|
9
|
+
run: async (_args, ctx) => {
|
|
10
|
+
if (!ctx?.userEmail)
|
|
11
|
+
throw new Error("Not authenticated.");
|
|
12
|
+
const stored = await getUserSetting(ctx.userEmail, LOCALIZATION_SETTING_KEY);
|
|
13
|
+
return normalizeLocalizationPreference(stored);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=get-localization-preference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-localization-preference.js","sourceRoot":"","sources":["../../../src/localization/actions/get-localization-preference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,+BAA+B,GAEhC,MAAM,cAAc,CAAC;AAEtB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,kIAAkI;IACpI,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAmC,EAAE;QACzD,IAAI,CAAC,GAAG,EAAE,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,GAAG,CAAC,SAAS,EACb,wBAAwB,CACzB,CAAC;QACF,OAAO,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { defineAction } from \"../../action.js\";\nimport { getUserSetting } from \"../../settings/user-settings.js\";\nimport {\n LOCALIZATION_SETTING_KEY,\n normalizeLocalizationPreference,\n type LocalizationPreference,\n} from \"../shared.js\";\n\nexport default defineAction({\n description:\n \"Get the current user's interface language preference. Returns { locale }, where locale is 'system' or a supported BCP-47 locale.\",\n schema: z.object({}),\n http: { method: \"GET\" },\n run: async (_args, ctx): Promise<LocalizationPreference> => {\n if (!ctx?.userEmail) throw new Error(\"Not authenticated.\");\n const stored = await getUserSetting(\n ctx.userEmail,\n LOCALIZATION_SETTING_KEY,\n );\n return normalizeLocalizationPreference(stored);\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-localization-preference.d.ts","sourceRoot":"","sources":["../../../src/localization/actions/set-localization-preference.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;;;;AAEtB,wBAoBG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../action.js";
|
|
3
|
+
import { putUserSetting } from "../../settings/user-settings.js";
|
|
4
|
+
import { LOCALIZATION_SETTING_KEY, normalizeLocalePreference, } from "../shared.js";
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description: "Set the current user's interface language preference to 'system' or a supported BCP-47 locale.",
|
|
7
|
+
schema: z.object({
|
|
8
|
+
locale: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe("Language preference: 'system' or a supported BCP-47 locale."),
|
|
11
|
+
}),
|
|
12
|
+
run: async (args, ctx) => {
|
|
13
|
+
if (!ctx?.userEmail)
|
|
14
|
+
throw new Error("Not authenticated.");
|
|
15
|
+
const locale = normalizeLocalePreference(args.locale);
|
|
16
|
+
if (!locale) {
|
|
17
|
+
throw new Error("Unsupported locale. Use system, en-US, zh-CN, es-ES, fr-FR, de-DE, ja-JP, ko-KR, pt-BR, hi-IN, or ar-SA.");
|
|
18
|
+
}
|
|
19
|
+
const value = { locale };
|
|
20
|
+
await putUserSetting(ctx.userEmail, LOCALIZATION_SETTING_KEY, value);
|
|
21
|
+
return value;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=set-localization-preference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-localization-preference.js","sourceRoot":"","sources":["../../../src/localization/actions/set-localization-preference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAE1B,MAAM,cAAc,CAAC;AAEtB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,gGAAgG;IAClG,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,CAAC,6DAA6D,CAAC;KAC3E,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAmC,EAAE;QACxD,IAAI,CAAC,GAAG,EAAE,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAqD,EAAE,MAAM,EAAE,CAAC;QAC3E,MAAM,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { defineAction } from \"../../action.js\";\nimport { putUserSetting } from \"../../settings/user-settings.js\";\nimport {\n LOCALIZATION_SETTING_KEY,\n normalizeLocalePreference,\n type LocalizationPreference,\n} from \"../shared.js\";\n\nexport default defineAction({\n description:\n \"Set the current user's interface language preference to 'system' or a supported BCP-47 locale.\",\n schema: z.object({\n locale: z\n .string()\n .describe(\"Language preference: 'system' or a supported BCP-47 locale.\"),\n }),\n run: async (args, ctx): Promise<LocalizationPreference> => {\n if (!ctx?.userEmail) throw new Error(\"Not authenticated.\");\n const locale = normalizeLocalePreference(args.locale);\n if (!locale) {\n throw new Error(\n \"Unsupported locale. Use system, en-US, zh-CN, es-ES, fr-FR, de-DE, ja-JP, ko-KR, pt-BR, hi-IN, or ar-SA.\",\n );\n }\n const value: LocalizationPreference & Record<string, unknown> = { locale };\n await putUserSetting(ctx.userEmail, LOCALIZATION_SETTING_KEY, value);\n return value;\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/localization/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/localization/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC","sourcesContent":["export * from \"./shared.js\";\nexport * from \"./server.js\";\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type LocaleCode, type LocalePreference, type LocalizationPreference } from "./shared.js";
|
|
2
|
+
interface RequestLike {
|
|
3
|
+
headers?: Headers | Record<string, string | string[] | undefined> | null;
|
|
4
|
+
}
|
|
5
|
+
export interface ResolvedRequestLocale {
|
|
6
|
+
locale: LocaleCode;
|
|
7
|
+
preference: LocalizationPreference;
|
|
8
|
+
dir: "ltr" | "rtl";
|
|
9
|
+
}
|
|
10
|
+
export interface ResolveLocaleFromRequestOptions {
|
|
11
|
+
request?: Request | RequestLike | null;
|
|
12
|
+
acceptLanguage?: string | null;
|
|
13
|
+
preference?: LocalizationPreference | LocalePreference | null;
|
|
14
|
+
fallback?: LocaleCode;
|
|
15
|
+
}
|
|
16
|
+
export interface LocaleInitScriptOptions {
|
|
17
|
+
locale?: LocaleCode;
|
|
18
|
+
preference?: LocalizationPreference | LocalePreference;
|
|
19
|
+
messages?: Record<string, unknown> | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseAcceptLanguage(header: string | null | undefined): string[];
|
|
22
|
+
export declare function resolveLocaleFromRequest(options?: ResolveLocaleFromRequestOptions): ResolvedRequestLocale;
|
|
23
|
+
export declare function getLocaleInitScript(options?: LocaleInitScriptOptions): string;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/localization/server.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AAErB,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;CAC1E;AAID,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,sBAAsB,CAAC;IACnC,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,sBAAsB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,sBAAsB,GAAG,gBAAgB,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAmBD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,YAkBpE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,+BAAoC,GAC5C,qBAAqB,CAsBvB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,UA4BxE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DEFAULT_LOCALE, LOCALE_HYDRATION_GLOBAL, LOCALE_STORAGE_KEY, SUPPORTED_LOCALES, localeDirection, normalizeLocaleCode, normalizeLocalizationPreference, resolveLocaleFromPreference, } from "./shared.js";
|
|
2
|
+
function readHeader(headers, key) {
|
|
3
|
+
if (!headers)
|
|
4
|
+
return null;
|
|
5
|
+
if (typeof headers.get === "function") {
|
|
6
|
+
return headers.get(key);
|
|
7
|
+
}
|
|
8
|
+
const lowerKey = key.toLowerCase();
|
|
9
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
10
|
+
if (name.toLowerCase() !== lowerKey)
|
|
11
|
+
continue;
|
|
12
|
+
if (Array.isArray(value))
|
|
13
|
+
return value.join(",");
|
|
14
|
+
return value ?? null;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export function parseAcceptLanguage(header) {
|
|
19
|
+
if (!header)
|
|
20
|
+
return [];
|
|
21
|
+
return header
|
|
22
|
+
.split(",")
|
|
23
|
+
.map((part) => {
|
|
24
|
+
const [tag, ...params] = part.trim().split(";");
|
|
25
|
+
const q = params
|
|
26
|
+
.map((param) => param.trim())
|
|
27
|
+
.find((param) => param.startsWith("q="));
|
|
28
|
+
const weight = q ? Number.parseFloat(q.slice(2)) : 1;
|
|
29
|
+
return {
|
|
30
|
+
tag,
|
|
31
|
+
weight: Number.isFinite(weight) ? weight : 0,
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
.filter((entry) => entry.tag && entry.weight > 0)
|
|
35
|
+
.sort((a, b) => b.weight - a.weight)
|
|
36
|
+
.map((entry) => entry.tag);
|
|
37
|
+
}
|
|
38
|
+
export function resolveLocaleFromRequest(options = {}) {
|
|
39
|
+
const header = options.acceptLanguage ??
|
|
40
|
+
readHeader(options.request?.headers, "accept-language");
|
|
41
|
+
const candidates = parseAcceptLanguage(header);
|
|
42
|
+
const preference = normalizeLocalizationPreference(options.preference ?? { locale: "system" });
|
|
43
|
+
const locale = preference.locale === "system"
|
|
44
|
+
? resolveLocaleFromPreference(preference, [
|
|
45
|
+
...candidates,
|
|
46
|
+
options.fallback ?? DEFAULT_LOCALE,
|
|
47
|
+
])
|
|
48
|
+
: (normalizeLocaleCode(preference.locale) ??
|
|
49
|
+
options.fallback ??
|
|
50
|
+
DEFAULT_LOCALE);
|
|
51
|
+
return {
|
|
52
|
+
locale,
|
|
53
|
+
preference,
|
|
54
|
+
dir: localeDirection(locale),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function getLocaleInitScript(options = {}) {
|
|
58
|
+
const safeLocale = normalizeLocaleCode(options.locale) ?? DEFAULT_LOCALE;
|
|
59
|
+
const shouldStorePreference = options.preference !== undefined;
|
|
60
|
+
const safePreference = normalizeLocalizationPreference(options.preference ?? { locale: "system" });
|
|
61
|
+
const payload = {
|
|
62
|
+
locale: safeLocale,
|
|
63
|
+
preference: safePreference,
|
|
64
|
+
dir: localeDirection(safeLocale),
|
|
65
|
+
messages: options.messages ?? undefined,
|
|
66
|
+
};
|
|
67
|
+
return `(function(){try{var supported=${JSON.stringify(SUPPORTED_LOCALES)};var payload=${JSON.stringify(payload)};var shouldStorePreference=${JSON.stringify(shouldStorePreference)};function valid(x){return supported.indexOf(x)>=0}function canon(x){if(typeof x!=='string'||!x)return null;try{var c=Intl.getCanonicalLocales(x)[0];if(valid(c))return c;var lang=c&&c.split('-')[0].toLowerCase();for(var i=0;i<supported.length;i++){if(supported[i].split('-')[0].toLowerCase()===lang)return supported[i]}}catch(e){}return null}function storageGet(k){try{return window.localStorage.getItem(k)}catch(e){return null}}function storageSet(k,v){try{window.localStorage.setItem(k,v)}catch(e){}}var stored=storageGet(${JSON.stringify(LOCALE_STORAGE_KEY)});var pref=payload.preference&&payload.preference.locale;var locale=payload.locale;if(!valid(locale)){locale=null}if(!locale&&stored&&stored!=='system'){locale=canon(stored)}if(!locale&&pref&&pref!=='system'){locale=canon(pref)}if(!locale){var langs=navigator.languages&&navigator.languages.length?navigator.languages:[navigator.language];for(var j=0;j<langs.length&&!locale;j++){locale=canon(langs[j])}}if(!locale)locale=${JSON.stringify(DEFAULT_LOCALE)};var root=document.documentElement;root.setAttribute('lang',locale);root.setAttribute('dir',locale==='ar-SA'?'rtl':'ltr');root.setAttribute('data-locale',locale);payload.locale=locale;payload.dir=locale==='ar-SA'?'rtl':'ltr';window[${JSON.stringify(LOCALE_HYDRATION_GLOBAL)}]=payload;if(shouldStorePreference&&pref){storageSet(${JSON.stringify(LOCALE_STORAGE_KEY)},pref)}}catch(e){}})();`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/localization/server.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n DEFAULT_LOCALE,\n LOCALE_HYDRATION_GLOBAL,\n LOCALE_STORAGE_KEY,\n SUPPORTED_LOCALES,\n localeDirection,\n normalizeLocaleCode,\n normalizeLocalizationPreference,\n resolveLocaleFromPreference,\n type LocaleCode,\n type LocalePreference,\n type LocalizationPreference,\n} from \"./shared.js\";\n\ninterface RequestLike {\n headers?: Headers | Record<string, string | string[] | undefined> | null;\n}\n\ntype HeaderMap = Headers | Record<string, string | string[] | undefined>;\n\nexport interface ResolvedRequestLocale {\n locale: LocaleCode;\n preference: LocalizationPreference;\n dir: \"ltr\" | \"rtl\";\n}\n\nexport interface ResolveLocaleFromRequestOptions {\n request?: Request | RequestLike | null;\n acceptLanguage?: string | null;\n preference?: LocalizationPreference | LocalePreference | null;\n fallback?: LocaleCode;\n}\n\nexport interface LocaleInitScriptOptions {\n locale?: LocaleCode;\n preference?: LocalizationPreference | LocalePreference;\n messages?: Record<string, unknown> | null;\n}\n\nfunction readHeader(\n headers: HeaderMap | undefined | null,\n key: string,\n): string | null {\n if (!headers) return null;\n if (typeof (headers as Headers).get === \"function\") {\n return (headers as Headers).get(key);\n }\n const lowerKey = key.toLowerCase();\n for (const [name, value] of Object.entries(headers)) {\n if (name.toLowerCase() !== lowerKey) continue;\n if (Array.isArray(value)) return value.join(\",\");\n return value ?? null;\n }\n return null;\n}\n\nexport function parseAcceptLanguage(header: string | null | undefined) {\n if (!header) return [];\n return header\n .split(\",\")\n .map((part) => {\n const [tag, ...params] = part.trim().split(\";\");\n const q = params\n .map((param) => param.trim())\n .find((param) => param.startsWith(\"q=\"));\n const weight = q ? Number.parseFloat(q.slice(2)) : 1;\n return {\n tag,\n weight: Number.isFinite(weight) ? weight : 0,\n };\n })\n .filter((entry) => entry.tag && entry.weight > 0)\n .sort((a, b) => b.weight - a.weight)\n .map((entry) => entry.tag);\n}\n\nexport function resolveLocaleFromRequest(\n options: ResolveLocaleFromRequestOptions = {},\n): ResolvedRequestLocale {\n const header =\n options.acceptLanguage ??\n readHeader(options.request?.headers, \"accept-language\");\n const candidates = parseAcceptLanguage(header);\n const preference = normalizeLocalizationPreference(\n options.preference ?? { locale: \"system\" },\n );\n const locale =\n preference.locale === \"system\"\n ? resolveLocaleFromPreference(preference, [\n ...candidates,\n options.fallback ?? DEFAULT_LOCALE,\n ])\n : (normalizeLocaleCode(preference.locale) ??\n options.fallback ??\n DEFAULT_LOCALE);\n return {\n locale,\n preference,\n dir: localeDirection(locale),\n };\n}\n\nexport function getLocaleInitScript(options: LocaleInitScriptOptions = {}) {\n const safeLocale = normalizeLocaleCode(options.locale) ?? DEFAULT_LOCALE;\n const shouldStorePreference = options.preference !== undefined;\n const safePreference = normalizeLocalizationPreference(\n options.preference ?? { locale: \"system\" },\n );\n const payload = {\n locale: safeLocale,\n preference: safePreference,\n dir: localeDirection(safeLocale),\n messages: options.messages ?? undefined,\n };\n\n return `(function(){try{var supported=${JSON.stringify(\n SUPPORTED_LOCALES,\n )};var payload=${JSON.stringify(\n payload,\n )};var shouldStorePreference=${JSON.stringify(\n shouldStorePreference,\n )};function valid(x){return supported.indexOf(x)>=0}function canon(x){if(typeof x!=='string'||!x)return null;try{var c=Intl.getCanonicalLocales(x)[0];if(valid(c))return c;var lang=c&&c.split('-')[0].toLowerCase();for(var i=0;i<supported.length;i++){if(supported[i].split('-')[0].toLowerCase()===lang)return supported[i]}}catch(e){}return null}function storageGet(k){try{return window.localStorage.getItem(k)}catch(e){return null}}function storageSet(k,v){try{window.localStorage.setItem(k,v)}catch(e){}}var stored=storageGet(${JSON.stringify(\n LOCALE_STORAGE_KEY,\n )});var pref=payload.preference&&payload.preference.locale;var locale=payload.locale;if(!valid(locale)){locale=null}if(!locale&&stored&&stored!=='system'){locale=canon(stored)}if(!locale&&pref&&pref!=='system'){locale=canon(pref)}if(!locale){var langs=navigator.languages&&navigator.languages.length?navigator.languages:[navigator.language];for(var j=0;j<langs.length&&!locale;j++){locale=canon(langs[j])}}if(!locale)locale=${JSON.stringify(\n DEFAULT_LOCALE,\n )};var root=document.documentElement;root.setAttribute('lang',locale);root.setAttribute('dir',locale==='ar-SA'?'rtl':'ltr');root.setAttribute('data-locale',locale);payload.locale=locale;payload.dir=locale==='ar-SA'?'rtl':'ltr';window[${JSON.stringify(\n LOCALE_HYDRATION_GLOBAL,\n )}]=payload;if(shouldStorePreference&&pref){storageSet(${JSON.stringify(\n LOCALE_STORAGE_KEY,\n )},pref)}}catch(e){}})();`;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const SUPPORTED_LOCALES: readonly ["en-US", "zh-CN", "es-ES", "fr-FR", "de-DE", "ja-JP", "ko-KR", "pt-BR", "hi-IN", "ar-SA"];
|
|
2
|
+
export type LocaleCode = (typeof SUPPORTED_LOCALES)[number];
|
|
3
|
+
export type LocalePreference = "system" | LocaleCode;
|
|
4
|
+
export interface LocaleMetadata {
|
|
5
|
+
code: LocaleCode;
|
|
6
|
+
englishName: string;
|
|
7
|
+
nativeName: string;
|
|
8
|
+
dir: "ltr" | "rtl";
|
|
9
|
+
}
|
|
10
|
+
export interface LocalizationPreference {
|
|
11
|
+
locale: LocalePreference;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_LOCALE: LocaleCode;
|
|
14
|
+
export declare const LOCALIZATION_SETTING_KEY = "localization";
|
|
15
|
+
export declare const LOCALE_STORAGE_KEY = "agent-native:locale-preference";
|
|
16
|
+
export declare const LOCALE_HYDRATION_GLOBAL = "__AGENT_NATIVE_LOCALE__";
|
|
17
|
+
export declare const LOCALE_METADATA: Record<LocaleCode, LocaleMetadata>;
|
|
18
|
+
export declare function isLocaleCode(value: unknown): value is LocaleCode;
|
|
19
|
+
export declare function normalizeLocaleCode(value: unknown): LocaleCode | null;
|
|
20
|
+
export declare function normalizeLocalePreference(value: unknown): LocalePreference | null;
|
|
21
|
+
export declare function normalizeLocalizationPreference(value: unknown): LocalizationPreference;
|
|
22
|
+
export declare function localeDirection(locale: LocaleCode): "ltr" | "rtl";
|
|
23
|
+
export declare function resolveLocaleFromCandidates(candidates: Iterable<unknown>): LocaleCode;
|
|
24
|
+
export declare function resolveLocaleFromPreference(preference: LocalizationPreference | LocalePreference | unknown, systemCandidates?: Iterable<unknown>): LocaleCode;
|
|
25
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/localization/shared.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qGAWpB,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,cAAc,EAAE,UAAoB,CAAC;AAClD,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AACnE,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,cAAc,CA6D9D,CAAC;AAIF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAerE;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,gBAAgB,GAAG,IAAI,CAGzB;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,GACb,sBAAsB,CASxB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,CAEjE;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAC5B,UAAU,CAMZ;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,sBAAsB,GAAG,gBAAgB,GAAG,OAAO,EAC/D,gBAAgB,GAAE,QAAQ,CAAC,OAAO,CAAM,GACvC,UAAU,CAOZ"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export const SUPPORTED_LOCALES = [
|
|
2
|
+
"en-US",
|
|
3
|
+
"zh-CN",
|
|
4
|
+
"es-ES",
|
|
5
|
+
"fr-FR",
|
|
6
|
+
"de-DE",
|
|
7
|
+
"ja-JP",
|
|
8
|
+
"ko-KR",
|
|
9
|
+
"pt-BR",
|
|
10
|
+
"hi-IN",
|
|
11
|
+
"ar-SA",
|
|
12
|
+
];
|
|
13
|
+
export const DEFAULT_LOCALE = "en-US";
|
|
14
|
+
export const LOCALIZATION_SETTING_KEY = "localization";
|
|
15
|
+
export const LOCALE_STORAGE_KEY = "agent-native:locale-preference";
|
|
16
|
+
export const LOCALE_HYDRATION_GLOBAL = "__AGENT_NATIVE_LOCALE__";
|
|
17
|
+
export const LOCALE_METADATA = {
|
|
18
|
+
"en-US": {
|
|
19
|
+
code: "en-US",
|
|
20
|
+
englishName: "English",
|
|
21
|
+
nativeName: "English",
|
|
22
|
+
dir: "ltr",
|
|
23
|
+
},
|
|
24
|
+
"zh-CN": {
|
|
25
|
+
code: "zh-CN",
|
|
26
|
+
englishName: "Chinese (Simplified)",
|
|
27
|
+
nativeName: "简体中文",
|
|
28
|
+
dir: "ltr",
|
|
29
|
+
},
|
|
30
|
+
"es-ES": {
|
|
31
|
+
code: "es-ES",
|
|
32
|
+
englishName: "Spanish",
|
|
33
|
+
nativeName: "Español",
|
|
34
|
+
dir: "ltr",
|
|
35
|
+
},
|
|
36
|
+
"fr-FR": {
|
|
37
|
+
code: "fr-FR",
|
|
38
|
+
englishName: "French",
|
|
39
|
+
nativeName: "Français",
|
|
40
|
+
dir: "ltr",
|
|
41
|
+
},
|
|
42
|
+
"de-DE": {
|
|
43
|
+
code: "de-DE",
|
|
44
|
+
englishName: "German",
|
|
45
|
+
nativeName: "Deutsch",
|
|
46
|
+
dir: "ltr",
|
|
47
|
+
},
|
|
48
|
+
"ja-JP": {
|
|
49
|
+
code: "ja-JP",
|
|
50
|
+
englishName: "Japanese",
|
|
51
|
+
nativeName: "日本語",
|
|
52
|
+
dir: "ltr",
|
|
53
|
+
},
|
|
54
|
+
"ko-KR": {
|
|
55
|
+
code: "ko-KR",
|
|
56
|
+
englishName: "Korean",
|
|
57
|
+
nativeName: "한국어",
|
|
58
|
+
dir: "ltr",
|
|
59
|
+
},
|
|
60
|
+
"pt-BR": {
|
|
61
|
+
code: "pt-BR",
|
|
62
|
+
englishName: "Portuguese (Brazil)",
|
|
63
|
+
nativeName: "Português (Brasil)",
|
|
64
|
+
dir: "ltr",
|
|
65
|
+
},
|
|
66
|
+
"hi-IN": {
|
|
67
|
+
code: "hi-IN",
|
|
68
|
+
englishName: "Hindi",
|
|
69
|
+
nativeName: "हिन्दी",
|
|
70
|
+
dir: "ltr",
|
|
71
|
+
},
|
|
72
|
+
"ar-SA": {
|
|
73
|
+
code: "ar-SA",
|
|
74
|
+
englishName: "Arabic",
|
|
75
|
+
nativeName: "العربية",
|
|
76
|
+
dir: "rtl",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
const SUPPORTED_LOCALE_SET = new Set(SUPPORTED_LOCALES);
|
|
80
|
+
export function isLocaleCode(value) {
|
|
81
|
+
return typeof value === "string" && SUPPORTED_LOCALE_SET.has(value);
|
|
82
|
+
}
|
|
83
|
+
export function normalizeLocaleCode(value) {
|
|
84
|
+
if (typeof value !== "string" || value.trim().length === 0)
|
|
85
|
+
return null;
|
|
86
|
+
try {
|
|
87
|
+
for (const canonical of Intl.getCanonicalLocales(value.trim())) {
|
|
88
|
+
if (isLocaleCode(canonical))
|
|
89
|
+
return canonical;
|
|
90
|
+
const language = canonical.split("-")[0]?.toLowerCase();
|
|
91
|
+
const match = SUPPORTED_LOCALES.find((locale) => locale.split("-")[0]?.toLowerCase() === language);
|
|
92
|
+
if (match)
|
|
93
|
+
return match;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
export function normalizeLocalePreference(value) {
|
|
102
|
+
if (value === "system")
|
|
103
|
+
return "system";
|
|
104
|
+
return normalizeLocaleCode(value);
|
|
105
|
+
}
|
|
106
|
+
export function normalizeLocalizationPreference(value) {
|
|
107
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
108
|
+
const locale = normalizeLocalePreference(value.locale);
|
|
109
|
+
if (locale)
|
|
110
|
+
return { locale };
|
|
111
|
+
}
|
|
112
|
+
const locale = normalizeLocalePreference(value);
|
|
113
|
+
return { locale: locale ?? "system" };
|
|
114
|
+
}
|
|
115
|
+
export function localeDirection(locale) {
|
|
116
|
+
return LOCALE_METADATA[locale]?.dir ?? "ltr";
|
|
117
|
+
}
|
|
118
|
+
export function resolveLocaleFromCandidates(candidates) {
|
|
119
|
+
for (const candidate of candidates) {
|
|
120
|
+
const normalized = normalizeLocaleCode(candidate);
|
|
121
|
+
if (normalized)
|
|
122
|
+
return normalized;
|
|
123
|
+
}
|
|
124
|
+
return DEFAULT_LOCALE;
|
|
125
|
+
}
|
|
126
|
+
export function resolveLocaleFromPreference(preference, systemCandidates = []) {
|
|
127
|
+
const normalized = typeof preference === "string"
|
|
128
|
+
? normalizeLocalePreference(preference)
|
|
129
|
+
: normalizeLocalizationPreference(preference).locale;
|
|
130
|
+
if (normalized && normalized !== "system")
|
|
131
|
+
return normalized;
|
|
132
|
+
return resolveLocaleFromCandidates(systemCandidates);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/localization/shared.ts"],"names":[],"mappings":"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","sourcesContent":["export const SUPPORTED_LOCALES = [\n \"en-US\",\n \"zh-CN\",\n \"es-ES\",\n \"fr-FR\",\n \"de-DE\",\n \"ja-JP\",\n \"ko-KR\",\n \"pt-BR\",\n \"hi-IN\",\n \"ar-SA\",\n] as const;\n\nexport type LocaleCode = (typeof SUPPORTED_LOCALES)[number];\nexport type LocalePreference = \"system\" | LocaleCode;\n\nexport interface LocaleMetadata {\n code: LocaleCode;\n englishName: string;\n nativeName: string;\n dir: \"ltr\" | \"rtl\";\n}\n\nexport interface LocalizationPreference {\n locale: LocalePreference;\n}\n\nexport const DEFAULT_LOCALE: LocaleCode = \"en-US\";\nexport const LOCALIZATION_SETTING_KEY = \"localization\";\nexport const LOCALE_STORAGE_KEY = \"agent-native:locale-preference\";\nexport const LOCALE_HYDRATION_GLOBAL = \"__AGENT_NATIVE_LOCALE__\";\n\nexport const LOCALE_METADATA: Record<LocaleCode, LocaleMetadata> = {\n \"en-US\": {\n code: \"en-US\",\n englishName: \"English\",\n nativeName: \"English\",\n dir: \"ltr\",\n },\n \"zh-CN\": {\n code: \"zh-CN\",\n englishName: \"Chinese (Simplified)\",\n nativeName: \"简体中文\",\n dir: \"ltr\",\n },\n \"es-ES\": {\n code: \"es-ES\",\n englishName: \"Spanish\",\n nativeName: \"Español\",\n dir: \"ltr\",\n },\n \"fr-FR\": {\n code: \"fr-FR\",\n englishName: \"French\",\n nativeName: \"Français\",\n dir: \"ltr\",\n },\n \"de-DE\": {\n code: \"de-DE\",\n englishName: \"German\",\n nativeName: \"Deutsch\",\n dir: \"ltr\",\n },\n \"ja-JP\": {\n code: \"ja-JP\",\n englishName: \"Japanese\",\n nativeName: \"日本語\",\n dir: \"ltr\",\n },\n \"ko-KR\": {\n code: \"ko-KR\",\n englishName: \"Korean\",\n nativeName: \"한국어\",\n dir: \"ltr\",\n },\n \"pt-BR\": {\n code: \"pt-BR\",\n englishName: \"Portuguese (Brazil)\",\n nativeName: \"Português (Brasil)\",\n dir: \"ltr\",\n },\n \"hi-IN\": {\n code: \"hi-IN\",\n englishName: \"Hindi\",\n nativeName: \"हिन्दी\",\n dir: \"ltr\",\n },\n \"ar-SA\": {\n code: \"ar-SA\",\n englishName: \"Arabic\",\n nativeName: \"العربية\",\n dir: \"rtl\",\n },\n};\n\nconst SUPPORTED_LOCALE_SET = new Set<string>(SUPPORTED_LOCALES);\n\nexport function isLocaleCode(value: unknown): value is LocaleCode {\n return typeof value === \"string\" && SUPPORTED_LOCALE_SET.has(value);\n}\n\nexport function normalizeLocaleCode(value: unknown): LocaleCode | null {\n if (typeof value !== \"string\" || value.trim().length === 0) return null;\n try {\n for (const canonical of Intl.getCanonicalLocales(value.trim())) {\n if (isLocaleCode(canonical)) return canonical;\n const language = canonical.split(\"-\")[0]?.toLowerCase();\n const match = SUPPORTED_LOCALES.find(\n (locale) => locale.split(\"-\")[0]?.toLowerCase() === language,\n );\n if (match) return match;\n }\n } catch {\n return null;\n }\n return null;\n}\n\nexport function normalizeLocalePreference(\n value: unknown,\n): LocalePreference | null {\n if (value === \"system\") return \"system\";\n return normalizeLocaleCode(value);\n}\n\nexport function normalizeLocalizationPreference(\n value: unknown,\n): LocalizationPreference {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const locale = normalizeLocalePreference(\n (value as { locale?: unknown }).locale,\n );\n if (locale) return { locale };\n }\n const locale = normalizeLocalePreference(value);\n return { locale: locale ?? \"system\" };\n}\n\nexport function localeDirection(locale: LocaleCode): \"ltr\" | \"rtl\" {\n return LOCALE_METADATA[locale]?.dir ?? \"ltr\";\n}\n\nexport function resolveLocaleFromCandidates(\n candidates: Iterable<unknown>,\n): LocaleCode {\n for (const candidate of candidates) {\n const normalized = normalizeLocaleCode(candidate);\n if (normalized) return normalized;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function resolveLocaleFromPreference(\n preference: LocalizationPreference | LocalePreference | unknown,\n systemCandidates: Iterable<unknown> = [],\n): LocaleCode {\n const normalized =\n typeof preference === \"string\"\n ? normalizeLocalePreference(preference)\n : normalizeLocalizationPreference(preference).locale;\n if (normalized && normalized !== \"system\") return normalized;\n return resolveLocaleFromCandidates(systemCandidates);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-discovery.d.ts","sourceRoot":"","sources":["../../src/server/action-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA4ChE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,IAAI,CAKN;AAqRD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAgGtC;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"action-discovery.d.ts","sourceRoot":"","sources":["../../src/server/action-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA4ChE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACnC,IAAI,CAKN;AAqRD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAgGtC;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CA2Ff;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,4BAAsB,CAAC"}
|
|
@@ -500,6 +500,14 @@ export async function mergeCoreSharingActions(registry) {
|
|
|
500
500
|
"context-report",
|
|
501
501
|
() => import("../agent/context-xray/actions/context-report.js"),
|
|
502
502
|
],
|
|
503
|
+
[
|
|
504
|
+
"get-localization-preference",
|
|
505
|
+
() => import("../localization/actions/get-localization-preference.js"),
|
|
506
|
+
],
|
|
507
|
+
[
|
|
508
|
+
"set-localization-preference",
|
|
509
|
+
() => import("../localization/actions/set-localization-preference.js"),
|
|
510
|
+
],
|
|
503
511
|
[
|
|
504
512
|
"change-appearance",
|
|
505
513
|
() => import("../appearance/actions/change-appearance.js"),
|