@aglyn/plugins-ai 1.31.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +2 -1
  2. package/package.json +17 -17
  3. package/src/lib/components/site-chat-api.d.ts +38 -0
  4. package/src/lib/components/site-chat-api.js +65 -0
  5. package/src/lib/components/site-chat-api.js.map +1 -0
  6. package/src/lib/components/site-chat-card.component.d.ts +31 -0
  7. package/src/lib/components/site-chat-card.component.js +474 -0
  8. package/src/lib/components/site-chat-card.component.js.map +1 -0
  9. package/src/lib/components/site-chat-panel.d.ts +38 -0
  10. package/src/lib/components/site-chat-panel.js +749 -0
  11. package/src/lib/components/site-chat-panel.js.map +1 -0
  12. package/src/lib/components/site-chat-runtime.d.ts +29 -0
  13. package/src/lib/components/site-chat-runtime.js +166 -0
  14. package/src/lib/components/site-chat-runtime.js.map +1 -0
  15. package/src/lib/declarations.js +5 -0
  16. package/src/lib/declarations.js.map +1 -1
  17. package/src/lib/jobs/ai-job-campaign-step.js +1 -0
  18. package/src/lib/jobs/ai-job-campaign-step.js.map +1 -1
  19. package/src/lib/jobs/ai-job-component-step.js +2 -1
  20. package/src/lib/jobs/ai-job-component-step.js.map +1 -1
  21. package/src/lib/jobs/ai-job-drafts.d.ts +8 -0
  22. package/src/lib/jobs/ai-job-drafts.js +18 -12
  23. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  24. package/src/lib/jobs/ai-job-edit-step.d.ts +5 -0
  25. package/src/lib/jobs/ai-job-edit-step.js +16 -9
  26. package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
  27. package/src/lib/jobs/ai-job-email-step.js +1 -0
  28. package/src/lib/jobs/ai-job-email-step.js.map +1 -1
  29. package/src/lib/jobs/ai-job-form-step.js +2 -1
  30. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-layout-step.js +4 -1
  32. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  33. package/src/lib/jobs/ai-job-navigation-step.js +7 -3
  34. package/src/lib/jobs/ai-job-navigation-step.js.map +1 -1
  35. package/src/lib/jobs/ai-job-page-step.js +7 -1
  36. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-privacy-step.d.ts +2 -0
  38. package/src/lib/jobs/ai-job-privacy-step.js +7 -4
  39. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-site-store-pages.js +3 -1
  41. package/src/lib/jobs/ai-job-site-store-pages.js.map +1 -1
  42. package/src/lib/jobs/ai-job-store-links-layout.js +8 -4
  43. package/src/lib/jobs/ai-job-store-links-layout.js.map +1 -1
  44. package/src/lib/jobs/ai-job-template-step.js +2 -1
  45. package/src/lib/jobs/ai-job-template-step.js.map +1 -1
  46. package/src/lib/jobs/ai-site-import-forms.js +2 -1
  47. package/src/lib/jobs/ai-site-import-forms.js.map +1 -1
  48. package/src/lib/jobs/ai-site-import-publish.d.ts +1 -1
  49. package/src/lib/jobs/ai-site-import-publish.js.map +1 -1
  50. package/src/lib/jobs/ai-site-late-photos.js +2 -1
  51. package/src/lib/jobs/ai-site-late-photos.js.map +1 -1
  52. package/src/lib/jobs/ai-site-publish.d.ts +2 -2
  53. package/src/lib/jobs/ai-site-publish.js +23 -15
  54. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  55. package/src/lib/layout-language/ai-layout-frame-source.js +1 -0
  56. package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
  57. package/src/lib/model/site-chat.d.ts +219 -0
  58. package/src/lib/model/site-chat.js +200 -0
  59. package/src/lib/model/site-chat.js.map +1 -0
  60. package/src/lib/plugin.js +10 -0
  61. package/src/lib/plugin.js.map +1 -1
  62. package/src/lib/runtime/ai-palette.generated.js +131 -0
  63. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  64. package/src/lib/server/ai-experiment-versions.js +6 -3
  65. package/src/lib/server/ai-experiment-versions.js.map +1 -1
  66. package/src/lib/server/ai-page-content.js +2 -1
  67. package/src/lib/server/ai-page-content.js.map +1 -1
  68. package/src/lib/server/ai-seo-apply.js +6 -3
  69. package/src/lib/server/ai-seo-apply.js.map +1 -1
  70. package/src/lib/server/site-chat-enricher.d.ts +29 -0
  71. package/src/lib/server/site-chat-enricher.js +41 -0
  72. package/src/lib/server/site-chat-enricher.js.map +1 -0
  73. package/src/lib/server/site-chat-owner-routes.d.ts +56 -0
  74. package/src/lib/server/site-chat-owner-routes.js +209 -0
  75. package/src/lib/server/site-chat-owner-routes.js.map +1 -0
  76. package/src/lib/server/site-chat-page-reads.d.ts +23 -0
  77. package/src/lib/server/site-chat-page-reads.js +32 -0
  78. package/src/lib/server/site-chat-page-reads.js.map +1 -0
  79. package/src/lib/server/site-chat-platform.d.ts +25 -0
  80. package/src/lib/server/site-chat-platform.js +405 -0
  81. package/src/lib/server/site-chat-platform.js.map +1 -0
  82. package/src/lib/server/site-chat-prompt.d.ts +83 -0
  83. package/src/lib/server/site-chat-prompt.js +166 -0
  84. package/src/lib/server/site-chat-prompt.js.map +1 -0
  85. package/src/lib/server/site-chat-session.d.ts +33 -0
  86. package/src/lib/server/site-chat-session.js +105 -0
  87. package/src/lib/server/site-chat-session.js.map +1 -0
  88. package/src/lib/server/site-chat-visitor-routes.d.ts +46 -0
  89. package/src/lib/server/site-chat-visitor-routes.js +105 -0
  90. package/src/lib/server/site-chat-visitor-routes.js.map +1 -0
  91. package/src/lib/server/site-chat.d.ts +119 -0
  92. package/src/lib/server/site-chat.js +500 -0
  93. package/src/lib/server/site-chat.js.map +1 -0
  94. package/src/lib/server.js +4 -0
  95. package/src/lib/server.js.map +1 -1
  96. package/src/lib/site-server.d.ts +23 -0
  97. package/src/lib/site-server.js +41 -0
  98. package/src/lib/site-server.js.map +1 -0
  99. package/src/lib/site.d.ts +23 -0
  100. package/src/lib/site.js +33 -0
  101. package/src/lib/site.js.map +1 -0
  102. package/src/lib/usage/site-chat-meter.d.ts +68 -0
  103. package/src/lib/usage/site-chat-meter.js +125 -0
  104. package/src/lib/usage/site-chat-meter.js.map +1 -0
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type SitePathListMode } from '@aglyn/aglyn/app-utils/site-path-patterns';
18
+ import type { SiteChatCapability, SiteChatCard, SiteChatProposal } from '@aglyn/aglyn/plugin-manager/plugin-site-chat-tools';
19
+ import type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types';
20
+ /**
21
+ * Aglyn AI on a published site (AGL-4250): the owner's settings, the slice a
22
+ * page carries, the wire format, and the site-chat credit allotment. Free of
23
+ * any server or React dependency, so the console card, the site runtime and
24
+ * the door read one definition.
25
+ */
26
+ /** The visitor's door, on the published site only (`tenantApi`). */
27
+ export declare const SITE_CHAT_ROUTE = "ai/site-chat";
28
+ /** The owner's settings, on the console only (`consoleApi`). */
29
+ export declare const SITE_CHAT_SETTINGS_ROUTE = "ai/site-chat/settings";
30
+ /** The owner's conversations and figures, on the console only. */
31
+ export declare const SITE_CHAT_CONVERSATIONS_ROUTE = "ai/site-chat/conversations";
32
+ /** A visitor's own conversation so far, on the published site. */
33
+ export declare const SITE_CHAT_HISTORY_ROUTE = "ai/site-chat/history";
34
+ /** The release flag, off by default; a released-off door answers 404. */
35
+ export declare const SITE_CHAT_RELEASE_FLAG = "release_ai_site_chat";
36
+ /** The site runtime's id: `contributes.site.features`. */
37
+ export declare const SITE_CHAT_RUNTIME_ID = "ai-site-chat";
38
+ /** The page prop the enricher answers. */
39
+ export declare const SITE_CHAT_PAGE_PROP = "aiSiteChat";
40
+ /** The console widget on a site's settings page. */
41
+ export declare const SITE_CHAT_WIDGET_ID = "ai-site-chat-settings";
42
+ /** `hosts/{hostId}/pluginSettings/{SITE_CHAT_SETTINGS_DOC}`. */
43
+ export declare const SITE_CHAT_SETTINGS_COLLECTION = "pluginSettings";
44
+ export declare const SITE_CHAT_SETTINGS_DOC = "ai-site-chat";
45
+ /** `hosts/{hostId}/siteChats/{conversationId}`: one per visitor session. */
46
+ export declare const SITE_CHATS_COLLECTION = "siteChats";
47
+ /** `orgs/{orgId}/siteChatUsage/{YYYY-MM}`: the allotment's meter. */
48
+ export declare const SITE_CHAT_USAGE_COLLECTION = "siteChatUsage";
49
+ /** The visitor session cookie, per site. */
50
+ export declare const siteChatCookieName: (hostId: string) => string;
51
+ export declare const SITE_CHAT_GREETING_MAX = 200;
52
+ export declare const SITE_CHAT_OPENING_MAX = 400;
53
+ export declare const SITE_CHAT_CHIP_MAX = 40;
54
+ export declare const SITE_CHAT_CHIPS_MAX = 4;
55
+ export declare const SITE_CHAT_MAX_PATHS = 50;
56
+ export declare const SITE_CHAT_MAX_PATH_LENGTH = 200;
57
+ /** What one visitor message may carry. */
58
+ export declare const SITE_CHAT_MESSAGE_MAX = 1000;
59
+ /** Turns one conversation may take in a day. */
60
+ export declare const SITE_CHAT_TURNS_PER_CONVERSATION = 30;
61
+ /** Turns the history keeps verbatim for the model. */
62
+ export declare const SITE_CHAT_HISTORY_TURNS = 8;
63
+ export declare const SITE_CHAT_DEFAULT_GREETING = "Hi! Ask me anything about us.";
64
+ export type SiteChatPosition = 'right' | 'left';
65
+ export interface SiteChatSettings {
66
+ enabled: boolean;
67
+ /** The first line in the panel. */
68
+ greeting: string;
69
+ /**
70
+ * The owner's opening message, shown once per visitor before they ask
71
+ * anything (a promotion, an announcement). '' for none.
72
+ */
73
+ openingMessage: string;
74
+ /** Suggested questions under the greeting. */
75
+ chips: string[];
76
+ /** What the chat may do besides answering. */
77
+ capabilities: SiteChatCapability[];
78
+ pages: SitePathListMode;
79
+ paths: string[];
80
+ position: SiteChatPosition;
81
+ /**
82
+ * The owner's own ceiling on what visitor chats may spend in a month, in
83
+ * credits, under the plan's site-chat allotment; `null` for the allotment.
84
+ */
85
+ monthlyCreditCap: number | null;
86
+ /** Hand a visitor to a person (the Inbox) when the chat cannot help. */
87
+ handOff: boolean;
88
+ }
89
+ export declare const SITE_CHAT_DEFAULT_SETTINGS: SiteChatSettings;
90
+ export type SiteChatSettingsResult = {
91
+ settings: SiteChatSettings;
92
+ } | {
93
+ error: string;
94
+ };
95
+ export declare function normalizeSiteChatSettings(input: unknown): SiteChatSettingsResult;
96
+ /** A stored document read back; anything unreadable is the defaults, off. */
97
+ export declare function readStoredSiteChatSettings(stored: unknown): SiteChatSettings;
98
+ /** What a page the chat shows on carries for the runtime. */
99
+ export interface SiteChatSlice {
100
+ greeting: string;
101
+ openingMessage: string;
102
+ chips: string[];
103
+ capabilities: SiteChatCapability[];
104
+ position: SiteChatPosition;
105
+ handOff: boolean;
106
+ }
107
+ export declare function siteChatSliceForPage(settings: SiteChatSettings, path: string, pathUnknown?: boolean): SiteChatSlice | null;
108
+ /** A slice off the page props, checked; `null` for anything else. */
109
+ export declare function readSiteChatSlice(value: unknown): SiteChatSlice | null;
110
+ /**
111
+ * Credits a month visitor chats may spend, by plan. They are the workspace's
112
+ * own AI credits (one pool, billed as every other AI request is), held under
113
+ * their own hard cap so a busy site can never drain what the team's console
114
+ * assistant runs on. Free has none: site chat is a Starter-and-up feature.
115
+ * An owner may set a lower cap per site; nothing raises it past these.
116
+ */
117
+ export declare const SITE_CHAT_CREDITS_BY_PLAN: Readonly<Record<OrgPlan, number>>;
118
+ /** The plan's allotment, `0` for a plan without site chat. */
119
+ export declare function siteChatPlanCredits(plan: OrgPlan | string | null | undefined): number;
120
+ /** Whether the plan includes site chat at all. */
121
+ export declare function siteChatOnPlan(plan: OrgPlan | string | null | undefined): boolean;
122
+ /**
123
+ * The ceiling one site's chats spend against this month: the plan's
124
+ * allotment for the workspace, narrowed by the site owner's own cap.
125
+ */
126
+ export declare function siteChatCeiling(planCredits: number, ownerCap: number | null | undefined): number;
127
+ /**
128
+ * Credits held for one turn before it runs. A turn costs a few credits on the
129
+ * fast tier; the hold is the most a turn is allowed to cost, so the cap can
130
+ * be passed by at most one turn's difference while two run at once.
131
+ */
132
+ export declare const SITE_CHAT_TURN_HOLD_CREDITS = 40;
133
+ /** A visitor's turn as the widget posts it. */
134
+ export interface SiteChatRequestBody {
135
+ hostId: string;
136
+ message: string;
137
+ /** The page the visitor is on, for "this page" questions. */
138
+ path?: string;
139
+ }
140
+ /**
141
+ * The events the door streams, one per `data:` line, the shape console
142
+ * Assist streams: text arrives as `delta`s and the turn ends with `done`.
143
+ */
144
+ export type SiteChatEvent = {
145
+ type: 'delta';
146
+ text: string;
147
+ } | {
148
+ type: 'cards';
149
+ cards: SiteChatCard[];
150
+ } | {
151
+ type: 'proposal';
152
+ proposal: SiteChatProposal;
153
+ } | {
154
+ type: 'handoff';
155
+ message: string;
156
+ } | {
157
+ type: 'done';
158
+ conversationId: string;
159
+ sources: SiteChatSource[];
160
+ } | {
161
+ type: 'error';
162
+ error: string;
163
+ reason?: string;
164
+ };
165
+ /** A page the answer used, linked under it. */
166
+ export interface SiteChatSource {
167
+ title: string;
168
+ url: string;
169
+ }
170
+ /** One stored turn of a conversation. */
171
+ export interface SiteChatTurn {
172
+ role: 'visitor' | 'assistant';
173
+ text: string;
174
+ at: number;
175
+ cards?: SiteChatCard[];
176
+ proposal?: SiteChatProposal;
177
+ sources?: SiteChatSource[];
178
+ }
179
+ /** What the console lists for a conversation. */
180
+ export interface SiteChatConversationSummary {
181
+ id: string;
182
+ startedAt: number;
183
+ updatedAt: number;
184
+ turns: number;
185
+ firstQuestion: string;
186
+ /** A proposal the visitor was shown, by kind. */
187
+ proposals: number;
188
+ handedOff: boolean;
189
+ member?: {
190
+ name: string;
191
+ } | null;
192
+ }
193
+ /** What a refusal says to a visitor; never a reason only staff should see. */
194
+ export declare const SITE_CHAT_UNAVAILABLE_COPY = "The chat is not available right now. Please call or email us, and we will be glad to help.";
195
+ export declare const SITE_CHAT_BUSY_COPY = "Lots of questions right now. Please try again in a minute.";
196
+ export declare const SITE_CHAT_CONVERSATION_LIMIT_COPY = "We have covered a lot today. For anything else, please call or email us.";
197
+ /** One site's month, for the owner's card. */
198
+ export interface SiteChatMonth {
199
+ month: string;
200
+ credits: number;
201
+ questions: number;
202
+ proposals: number;
203
+ conversations: number;
204
+ /** What the workspace's sites spent together. */
205
+ workspaceCredits: number;
206
+ }
207
+ /** What the owner's settings door answers. */
208
+ export interface SiteChatSettingsAnswer {
209
+ settings: SiteChatSettings;
210
+ canManage: boolean;
211
+ /** The plan includes site chat (Starter and up). */
212
+ onPlan: boolean;
213
+ /** The release flag is on for the workspace. */
214
+ released: boolean;
215
+ /** The plan's allotment, the ceiling this site spends against, and the month. */
216
+ planCredits: number;
217
+ ceiling: number;
218
+ month: SiteChatMonth | null;
219
+ }
@@ -0,0 +1,200 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { normalizeSitePathList, sitePathListShows } from "@aglyn/aglyn/app-utils/site-path-patterns";
18
+ /**
19
+ * Aglyn AI on a published site (AGL-4250): the owner's settings, the slice a
20
+ * page carries, the wire format, and the site-chat credit allotment. Free of
21
+ * any server or React dependency, so the console card, the site runtime and
22
+ * the door read one definition.
23
+ */ /** The visitor's door, on the published site only (`tenantApi`). */ export const SITE_CHAT_ROUTE = 'ai/site-chat';
24
+ /** The owner's settings, on the console only (`consoleApi`). */ export const SITE_CHAT_SETTINGS_ROUTE = 'ai/site-chat/settings';
25
+ /** The owner's conversations and figures, on the console only. */ export const SITE_CHAT_CONVERSATIONS_ROUTE = 'ai/site-chat/conversations';
26
+ /** A visitor's own conversation so far, on the published site. */ export const SITE_CHAT_HISTORY_ROUTE = 'ai/site-chat/history';
27
+ /** The release flag, off by default; a released-off door answers 404. */ export const SITE_CHAT_RELEASE_FLAG = 'release_ai_site_chat';
28
+ /** The site runtime's id: `contributes.site.features`. */ export const SITE_CHAT_RUNTIME_ID = 'ai-site-chat';
29
+ /** The page prop the enricher answers. */ export const SITE_CHAT_PAGE_PROP = 'aiSiteChat';
30
+ /** The console widget on a site's settings page. */ export const SITE_CHAT_WIDGET_ID = 'ai-site-chat-settings';
31
+ /** `hosts/{hostId}/pluginSettings/{SITE_CHAT_SETTINGS_DOC}`. */ export const SITE_CHAT_SETTINGS_COLLECTION = 'pluginSettings';
32
+ export const SITE_CHAT_SETTINGS_DOC = 'ai-site-chat';
33
+ /** `hosts/{hostId}/siteChats/{conversationId}`: one per visitor session. */ export const SITE_CHATS_COLLECTION = 'siteChats';
34
+ /** `orgs/{orgId}/siteChatUsage/{YYYY-MM}`: the allotment's meter. */ export const SITE_CHAT_USAGE_COLLECTION = 'siteChatUsage';
35
+ /** The visitor session cookie, per site. */ export const siteChatCookieName = (hostId)=>`aglyn_chat_${hostId}`;
36
+ export const SITE_CHAT_GREETING_MAX = 200;
37
+ export const SITE_CHAT_OPENING_MAX = 400;
38
+ export const SITE_CHAT_CHIP_MAX = 40;
39
+ export const SITE_CHAT_CHIPS_MAX = 4;
40
+ export const SITE_CHAT_MAX_PATHS = 50;
41
+ export const SITE_CHAT_MAX_PATH_LENGTH = 200;
42
+ /** What one visitor message may carry. */ export const SITE_CHAT_MESSAGE_MAX = 1000;
43
+ /** Turns one conversation may take in a day. */ export const SITE_CHAT_TURNS_PER_CONVERSATION = 30;
44
+ /** Turns the history keeps verbatim for the model. */ export const SITE_CHAT_HISTORY_TURNS = 8;
45
+ export const SITE_CHAT_DEFAULT_GREETING = 'Hi! Ask me anything about us.';
46
+ export const SITE_CHAT_DEFAULT_SETTINGS = {
47
+ enabled: false,
48
+ greeting: SITE_CHAT_DEFAULT_GREETING,
49
+ openingMessage: '',
50
+ chips: [],
51
+ capabilities: [
52
+ 'answer'
53
+ ],
54
+ pages: 'all',
55
+ paths: [],
56
+ position: 'right',
57
+ monthlyCreditCap: null,
58
+ handOff: true
59
+ };
60
+ const CAPABILITY_SET = [
61
+ 'answer',
62
+ 'cart',
63
+ 'book'
64
+ ];
65
+ const clean = (value, max)=>typeof value === 'string' ? value.replace(/\s+/g, ' ').trim().slice(0, max) : '';
66
+ export function normalizeSiteChatSettings(input) {
67
+ var _raw_pages;
68
+ const raw = input && typeof input === 'object' ? input : {};
69
+ const greetingText = typeof raw['greeting'] === 'string' ? raw['greeting'].trim() : '';
70
+ if (greetingText.length > SITE_CHAT_GREETING_MAX) {
71
+ return {
72
+ error: `Keep the greeting under ${SITE_CHAT_GREETING_MAX} characters.`
73
+ };
74
+ }
75
+ const openingText = typeof raw['openingMessage'] === 'string' ? raw['openingMessage'].trim() : '';
76
+ if (openingText.length > SITE_CHAT_OPENING_MAX) {
77
+ return {
78
+ error: `Keep the opening message under ${SITE_CHAT_OPENING_MAX} characters.`
79
+ };
80
+ }
81
+ const chips = [];
82
+ for (const entry of Array.isArray(raw['chips']) ? raw['chips'] : []){
83
+ const chip = clean(entry, 200);
84
+ if (!chip) continue;
85
+ if (chip.length > SITE_CHAT_CHIP_MAX) {
86
+ return {
87
+ error: `Keep each suggested question under ${SITE_CHAT_CHIP_MAX} characters.`
88
+ };
89
+ }
90
+ if (!chips.includes(chip)) chips.push(chip);
91
+ }
92
+ if (chips.length > SITE_CHAT_CHIPS_MAX) {
93
+ return {
94
+ error: `Offer at most ${SITE_CHAT_CHIPS_MAX} suggested questions.`
95
+ };
96
+ }
97
+ const capabilities = CAPABILITY_SET.filter((capability)=>capability === 'answer' || Array.isArray(raw['capabilities']) && raw['capabilities'].includes(capability));
98
+ const list = normalizeSitePathList({
99
+ pages: (_raw_pages = raw['pages']) != null ? _raw_pages : 'all',
100
+ paths: raw['paths']
101
+ }, {
102
+ noun: 'the chat',
103
+ maxPaths: SITE_CHAT_MAX_PATHS,
104
+ maxLength: SITE_CHAT_MAX_PATH_LENGTH
105
+ });
106
+ if ('error' in list) return {
107
+ error: list.error
108
+ };
109
+ let monthlyCreditCap = null;
110
+ if (raw['monthlyCreditCap'] !== null && raw['monthlyCreditCap'] !== undefined && raw['monthlyCreditCap'] !== '') {
111
+ const cap = Number(raw['monthlyCreditCap']);
112
+ if (!Number.isFinite(cap) || cap < 0) return {
113
+ error: 'The monthly cap is a number of credits, 0 or more.'
114
+ };
115
+ monthlyCreditCap = Math.min(10000000, Math.floor(cap));
116
+ }
117
+ return {
118
+ settings: {
119
+ enabled: raw['enabled'] === true,
120
+ greeting: greetingText.replace(/\s+/g, ' ') || SITE_CHAT_DEFAULT_GREETING,
121
+ openingMessage: openingText.replace(/[ \t]+/g, ' '),
122
+ chips,
123
+ capabilities,
124
+ pages: list.pages,
125
+ paths: list.paths,
126
+ position: raw['position'] === 'left' ? 'left' : 'right',
127
+ monthlyCreditCap,
128
+ handOff: raw['handOff'] !== false
129
+ }
130
+ };
131
+ }
132
+ /** A stored document read back; anything unreadable is the defaults, off. */ export function readStoredSiteChatSettings(stored) {
133
+ if (!stored || typeof stored !== 'object') return _extends({}, SITE_CHAT_DEFAULT_SETTINGS);
134
+ const result = normalizeSiteChatSettings(stored);
135
+ return 'error' in result ? _extends({}, SITE_CHAT_DEFAULT_SETTINGS) : result.settings;
136
+ }
137
+ export function siteChatSliceForPage(settings, path, pathUnknown = false) {
138
+ if (!settings.enabled) return null;
139
+ if (!sitePathListShows(settings, path, pathUnknown)) return null;
140
+ return {
141
+ greeting: settings.greeting,
142
+ openingMessage: settings.openingMessage,
143
+ chips: settings.chips,
144
+ capabilities: settings.capabilities,
145
+ position: settings.position,
146
+ handOff: settings.handOff
147
+ };
148
+ }
149
+ /** A slice off the page props, checked; `null` for anything else. */ export function readSiteChatSlice(value) {
150
+ if (!value || typeof value !== 'object') return null;
151
+ const raw = value;
152
+ const greeting = clean(raw['greeting'], SITE_CHAT_GREETING_MAX);
153
+ if (!greeting) return null;
154
+ return {
155
+ greeting,
156
+ openingMessage: typeof raw['openingMessage'] === 'string' ? raw['openingMessage'].slice(0, SITE_CHAT_OPENING_MAX) : '',
157
+ chips: (Array.isArray(raw['chips']) ? raw['chips'] : []).map((chip)=>clean(chip, SITE_CHAT_CHIP_MAX)).filter(Boolean).slice(0, SITE_CHAT_CHIPS_MAX),
158
+ capabilities: CAPABILITY_SET.filter((capability)=>capability === 'answer' || Array.isArray(raw['capabilities']) && raw['capabilities'].includes(capability)),
159
+ position: raw['position'] === 'left' ? 'left' : 'right',
160
+ handOff: raw['handOff'] !== false
161
+ };
162
+ }
163
+ // ── The site-chat allotment ────────────────────────────────────────────────
164
+ /**
165
+ * Credits a month visitor chats may spend, by plan. They are the workspace's
166
+ * own AI credits (one pool, billed as every other AI request is), held under
167
+ * their own hard cap so a busy site can never drain what the team's console
168
+ * assistant runs on. Free has none: site chat is a Starter-and-up feature.
169
+ * An owner may set a lower cap per site; nothing raises it past these.
170
+ */ export const SITE_CHAT_CREDITS_BY_PLAN = {
171
+ free: 0,
172
+ starter: 1000,
173
+ pro: 5000,
174
+ enterprise: 20000
175
+ };
176
+ /** The plan's allotment, `0` for a plan without site chat. */ export function siteChatPlanCredits(plan) {
177
+ var _SITE_CHAT_CREDITS_BY_PLAN_plan;
178
+ return (_SITE_CHAT_CREDITS_BY_PLAN_plan = SITE_CHAT_CREDITS_BY_PLAN[plan]) != null ? _SITE_CHAT_CREDITS_BY_PLAN_plan : 0;
179
+ }
180
+ /** Whether the plan includes site chat at all. */ export function siteChatOnPlan(plan) {
181
+ return siteChatPlanCredits(plan) > 0;
182
+ }
183
+ /**
184
+ * The ceiling one site's chats spend against this month: the plan's
185
+ * allotment for the workspace, narrowed by the site owner's own cap.
186
+ */ export function siteChatCeiling(planCredits, ownerCap) {
187
+ const plan = Math.max(0, Math.floor(Number(planCredits) || 0));
188
+ if (ownerCap === null || ownerCap === undefined) return plan;
189
+ return Math.min(plan, Math.max(0, Math.floor(Number(ownerCap) || 0)));
190
+ }
191
+ /**
192
+ * Credits held for one turn before it runs. A turn costs a few credits on the
193
+ * fast tier; the hold is the most a turn is allowed to cost, so the cap can
194
+ * be passed by at most one turn's difference while two run at once.
195
+ */ export const SITE_CHAT_TURN_HOLD_CREDITS = 40;
196
+ /** What a refusal says to a visitor; never a reason only staff should see. */ export const SITE_CHAT_UNAVAILABLE_COPY = 'The chat is not available right now. Please call or email us, and we will be glad to help.';
197
+ export const SITE_CHAT_BUSY_COPY = 'Lots of questions right now. Please try again in a minute.';
198
+ export const SITE_CHAT_CONVERSATION_LIMIT_COPY = 'We have covered a lot today. For anything else, please call or email us.';
199
+
200
+ //# sourceMappingURL=site-chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/site-chat.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n normalizeSitePathList,\n sitePathListShows,\n type SitePathListMode,\n} from '@aglyn/aglyn/app-utils/site-path-patterns'\nimport type {\n SiteChatCapability,\n SiteChatCard,\n SiteChatProposal,\n} from '@aglyn/aglyn/plugin-manager/plugin-site-chat-tools'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\n\n/**\n * Aglyn AI on a published site (AGL-4250): the owner's settings, the slice a\n * page carries, the wire format, and the site-chat credit allotment. Free of\n * any server or React dependency, so the console card, the site runtime and\n * the door read one definition.\n */\n\n/** The visitor's door, on the published site only (`tenantApi`). */\nexport const SITE_CHAT_ROUTE = 'ai/site-chat'\n/** The owner's settings, on the console only (`consoleApi`). */\nexport const SITE_CHAT_SETTINGS_ROUTE = 'ai/site-chat/settings'\n/** The owner's conversations and figures, on the console only. */\nexport const SITE_CHAT_CONVERSATIONS_ROUTE = 'ai/site-chat/conversations'\n/** A visitor's own conversation so far, on the published site. */\nexport const SITE_CHAT_HISTORY_ROUTE = 'ai/site-chat/history'\n\n/** The release flag, off by default; a released-off door answers 404. */\nexport const SITE_CHAT_RELEASE_FLAG = 'release_ai_site_chat'\n\n/** The site runtime's id: `contributes.site.features`. */\nexport const SITE_CHAT_RUNTIME_ID = 'ai-site-chat'\n/** The page prop the enricher answers. */\nexport const SITE_CHAT_PAGE_PROP = 'aiSiteChat'\n/** The console widget on a site's settings page. */\nexport const SITE_CHAT_WIDGET_ID = 'ai-site-chat-settings'\n\n/** `hosts/{hostId}/pluginSettings/{SITE_CHAT_SETTINGS_DOC}`. */\nexport const SITE_CHAT_SETTINGS_COLLECTION = 'pluginSettings'\nexport const SITE_CHAT_SETTINGS_DOC = 'ai-site-chat'\n/** `hosts/{hostId}/siteChats/{conversationId}`: one per visitor session. */\nexport const SITE_CHATS_COLLECTION = 'siteChats'\n/** `orgs/{orgId}/siteChatUsage/{YYYY-MM}`: the allotment's meter. */\nexport const SITE_CHAT_USAGE_COLLECTION = 'siteChatUsage'\n\n/** The visitor session cookie, per site. */\nexport const siteChatCookieName = (hostId: string): string => `aglyn_chat_${hostId}`\n\nexport const SITE_CHAT_GREETING_MAX = 200\nexport const SITE_CHAT_OPENING_MAX = 400\nexport const SITE_CHAT_CHIP_MAX = 40\nexport const SITE_CHAT_CHIPS_MAX = 4\nexport const SITE_CHAT_MAX_PATHS = 50\nexport const SITE_CHAT_MAX_PATH_LENGTH = 200\n/** What one visitor message may carry. */\nexport const SITE_CHAT_MESSAGE_MAX = 1_000\n/** Turns one conversation may take in a day. */\nexport const SITE_CHAT_TURNS_PER_CONVERSATION = 30\n/** Turns the history keeps verbatim for the model. */\nexport const SITE_CHAT_HISTORY_TURNS = 8\n\nexport const SITE_CHAT_DEFAULT_GREETING = 'Hi! Ask me anything about us.'\n\nexport type SiteChatPosition = 'right' | 'left'\n\nexport interface SiteChatSettings {\n enabled: boolean\n /** The first line in the panel. */\n greeting: string\n /**\n * The owner's opening message, shown once per visitor before they ask\n * anything (a promotion, an announcement). '' for none.\n */\n openingMessage: string\n /** Suggested questions under the greeting. */\n chips: string[]\n /** What the chat may do besides answering. */\n capabilities: SiteChatCapability[]\n pages: SitePathListMode\n paths: string[]\n position: SiteChatPosition\n /**\n * The owner's own ceiling on what visitor chats may spend in a month, in\n * credits, under the plan's site-chat allotment; `null` for the allotment.\n */\n monthlyCreditCap: number | null\n /** Hand a visitor to a person (the Inbox) when the chat cannot help. */\n handOff: boolean\n}\n\nexport const SITE_CHAT_DEFAULT_SETTINGS: SiteChatSettings = {\n enabled: false,\n greeting: SITE_CHAT_DEFAULT_GREETING,\n openingMessage: '',\n chips: [],\n capabilities: ['answer'],\n pages: 'all',\n paths: [],\n position: 'right',\n monthlyCreditCap: null,\n handOff: true,\n}\n\nconst CAPABILITY_SET: readonly SiteChatCapability[] = ['answer', 'cart', 'book']\n\nconst clean = (value: unknown, max: number): string =>\n typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim().slice(0, max) : ''\n\nexport type SiteChatSettingsResult = { settings: SiteChatSettings } | { error: string }\n\nexport function normalizeSiteChatSettings(input: unknown): SiteChatSettingsResult {\n const raw = (input && typeof input === 'object' ? input : {}) as Record<string, unknown>\n const greetingText = typeof raw['greeting'] === 'string' ? raw['greeting'].trim() : ''\n if (greetingText.length > SITE_CHAT_GREETING_MAX) {\n return { error: `Keep the greeting under ${SITE_CHAT_GREETING_MAX} characters.` }\n }\n const openingText = typeof raw['openingMessage'] === 'string' ? raw['openingMessage'].trim() : ''\n if (openingText.length > SITE_CHAT_OPENING_MAX) {\n return { error: `Keep the opening message under ${SITE_CHAT_OPENING_MAX} characters.` }\n }\n const chips: string[] = []\n for (const entry of Array.isArray(raw['chips']) ? raw['chips'] : []) {\n const chip = clean(entry, 200)\n if (!chip) continue\n if (chip.length > SITE_CHAT_CHIP_MAX) {\n return { error: `Keep each suggested question under ${SITE_CHAT_CHIP_MAX} characters.` }\n }\n if (!chips.includes(chip)) chips.push(chip)\n }\n if (chips.length > SITE_CHAT_CHIPS_MAX) {\n return { error: `Offer at most ${SITE_CHAT_CHIPS_MAX} suggested questions.` }\n }\n const capabilities = CAPABILITY_SET.filter(\n (capability) =>\n capability === 'answer' ||\n (Array.isArray(raw['capabilities']) && raw['capabilities'].includes(capability)),\n )\n const list = normalizeSitePathList(\n { pages: raw['pages'] ?? 'all', paths: raw['paths'] },\n { noun: 'the chat', maxPaths: SITE_CHAT_MAX_PATHS, maxLength: SITE_CHAT_MAX_PATH_LENGTH },\n )\n if ('error' in list) return { error: list.error }\n let monthlyCreditCap: number | null = null\n if (raw['monthlyCreditCap'] !== null && raw['monthlyCreditCap'] !== undefined && raw['monthlyCreditCap'] !== '') {\n const cap = Number(raw['monthlyCreditCap'])\n if (!Number.isFinite(cap) || cap < 0) return { error: 'The monthly cap is a number of credits, 0 or more.' }\n monthlyCreditCap = Math.min(10_000_000, Math.floor(cap))\n }\n return {\n settings: {\n enabled: raw['enabled'] === true,\n greeting: greetingText.replace(/\\s+/g, ' ') || SITE_CHAT_DEFAULT_GREETING,\n openingMessage: openingText.replace(/[ \\t]+/g, ' '),\n chips,\n capabilities,\n pages: list.pages,\n paths: list.paths,\n position: raw['position'] === 'left' ? 'left' : 'right',\n monthlyCreditCap,\n handOff: raw['handOff'] !== false,\n },\n }\n}\n\n/** A stored document read back; anything unreadable is the defaults, off. */\nexport function readStoredSiteChatSettings(stored: unknown): SiteChatSettings {\n if (!stored || typeof stored !== 'object') return { ...SITE_CHAT_DEFAULT_SETTINGS }\n const result = normalizeSiteChatSettings(stored)\n return 'error' in result ? { ...SITE_CHAT_DEFAULT_SETTINGS } : result.settings\n}\n\n/** What a page the chat shows on carries for the runtime. */\nexport interface SiteChatSlice {\n greeting: string\n openingMessage: string\n chips: string[]\n capabilities: SiteChatCapability[]\n position: SiteChatPosition\n handOff: boolean\n}\n\nexport function siteChatSliceForPage(\n settings: SiteChatSettings,\n path: string,\n pathUnknown = false,\n): SiteChatSlice | null {\n if (!settings.enabled) return null\n if (!sitePathListShows(settings, path, pathUnknown)) return null\n return {\n greeting: settings.greeting,\n openingMessage: settings.openingMessage,\n chips: settings.chips,\n capabilities: settings.capabilities,\n position: settings.position,\n handOff: settings.handOff,\n }\n}\n\n/** A slice off the page props, checked; `null` for anything else. */\nexport function readSiteChatSlice(value: unknown): SiteChatSlice | null {\n if (!value || typeof value !== 'object') return null\n const raw = value as Record<string, unknown>\n const greeting = clean(raw['greeting'], SITE_CHAT_GREETING_MAX)\n if (!greeting) return null\n return {\n greeting,\n openingMessage:\n typeof raw['openingMessage'] === 'string' ? raw['openingMessage'].slice(0, SITE_CHAT_OPENING_MAX) : '',\n chips: (Array.isArray(raw['chips']) ? raw['chips'] : [])\n .map((chip) => clean(chip, SITE_CHAT_CHIP_MAX))\n .filter(Boolean)\n .slice(0, SITE_CHAT_CHIPS_MAX),\n capabilities: CAPABILITY_SET.filter(\n (capability) =>\n capability === 'answer' || (Array.isArray(raw['capabilities']) && raw['capabilities'].includes(capability)),\n ),\n position: raw['position'] === 'left' ? 'left' : 'right',\n handOff: raw['handOff'] !== false,\n }\n}\n\n// ── The site-chat allotment ────────────────────────────────────────────────\n\n/**\n * Credits a month visitor chats may spend, by plan. They are the workspace's\n * own AI credits (one pool, billed as every other AI request is), held under\n * their own hard cap so a busy site can never drain what the team's console\n * assistant runs on. Free has none: site chat is a Starter-and-up feature.\n * An owner may set a lower cap per site; nothing raises it past these.\n */\nexport const SITE_CHAT_CREDITS_BY_PLAN: Readonly<Record<OrgPlan, number>> = {\n free: 0,\n starter: 1_000,\n pro: 5_000,\n enterprise: 20_000,\n}\n\n/** The plan's allotment, `0` for a plan without site chat. */\nexport function siteChatPlanCredits(plan: OrgPlan | string | null | undefined): number {\n return SITE_CHAT_CREDITS_BY_PLAN[plan as OrgPlan] ?? 0\n}\n\n/** Whether the plan includes site chat at all. */\nexport function siteChatOnPlan(plan: OrgPlan | string | null | undefined): boolean {\n return siteChatPlanCredits(plan) > 0\n}\n\n/**\n * The ceiling one site's chats spend against this month: the plan's\n * allotment for the workspace, narrowed by the site owner's own cap.\n */\nexport function siteChatCeiling(\n planCredits: number,\n ownerCap: number | null | undefined,\n): number {\n const plan = Math.max(0, Math.floor(Number(planCredits) || 0))\n if (ownerCap === null || ownerCap === undefined) return plan\n return Math.min(plan, Math.max(0, Math.floor(Number(ownerCap) || 0)))\n}\n\n/**\n * Credits held for one turn before it runs. A turn costs a few credits on the\n * fast tier; the hold is the most a turn is allowed to cost, so the cap can\n * be passed by at most one turn's difference while two run at once.\n */\nexport const SITE_CHAT_TURN_HOLD_CREDITS = 40\n\n// ── The wire format ────────────────────────────────────────────────────────\n\n/** A visitor's turn as the widget posts it. */\nexport interface SiteChatRequestBody {\n hostId: string\n message: string\n /** The page the visitor is on, for \"this page\" questions. */\n path?: string\n}\n\n/**\n * The events the door streams, one per `data:` line, the shape console\n * Assist streams: text arrives as `delta`s and the turn ends with `done`.\n */\nexport type SiteChatEvent =\n | { type: 'delta'; text: string }\n | { type: 'cards'; cards: SiteChatCard[] }\n | { type: 'proposal'; proposal: SiteChatProposal }\n | { type: 'handoff'; message: string }\n | { type: 'done'; conversationId: string; sources: SiteChatSource[] }\n | { type: 'error'; error: string; reason?: string }\n\n/** A page the answer used, linked under it. */\nexport interface SiteChatSource {\n title: string\n url: string\n}\n\n/** One stored turn of a conversation. */\nexport interface SiteChatTurn {\n role: 'visitor' | 'assistant'\n text: string\n at: number\n cards?: SiteChatCard[]\n proposal?: SiteChatProposal\n sources?: SiteChatSource[]\n}\n\n/** What the console lists for a conversation. */\nexport interface SiteChatConversationSummary {\n id: string\n startedAt: number\n updatedAt: number\n turns: number\n firstQuestion: string\n /** A proposal the visitor was shown, by kind. */\n proposals: number\n handedOff: boolean\n member?: { name: string } | null\n}\n\n/** What a refusal says to a visitor; never a reason only staff should see. */\nexport const SITE_CHAT_UNAVAILABLE_COPY =\n 'The chat is not available right now. Please call or email us, and we will be glad to help.'\nexport const SITE_CHAT_BUSY_COPY = 'Lots of questions right now. Please try again in a minute.'\nexport const SITE_CHAT_CONVERSATION_LIMIT_COPY =\n 'We have covered a lot today. For anything else, please call or email us.'\n\n/** One site's month, for the owner's card. */\nexport interface SiteChatMonth {\n month: string\n credits: number\n questions: number\n proposals: number\n conversations: number\n /** What the workspace's sites spent together. */\n workspaceCredits: number\n}\n\n/** What the owner's settings door answers. */\nexport interface SiteChatSettingsAnswer {\n settings: SiteChatSettings\n canManage: boolean\n /** The plan includes site chat (Starter and up). */\n onPlan: boolean\n /** The release flag is on for the workspace. */\n released: boolean\n /** The plan's allotment, the ceiling this site spends against, and the month. */\n planCredits: number\n ceiling: number\n month: SiteChatMonth | null\n}\n"],"names":["normalizeSitePathList","sitePathListShows","SITE_CHAT_ROUTE","SITE_CHAT_SETTINGS_ROUTE","SITE_CHAT_CONVERSATIONS_ROUTE","SITE_CHAT_HISTORY_ROUTE","SITE_CHAT_RELEASE_FLAG","SITE_CHAT_RUNTIME_ID","SITE_CHAT_PAGE_PROP","SITE_CHAT_WIDGET_ID","SITE_CHAT_SETTINGS_COLLECTION","SITE_CHAT_SETTINGS_DOC","SITE_CHATS_COLLECTION","SITE_CHAT_USAGE_COLLECTION","siteChatCookieName","hostId","SITE_CHAT_GREETING_MAX","SITE_CHAT_OPENING_MAX","SITE_CHAT_CHIP_MAX","SITE_CHAT_CHIPS_MAX","SITE_CHAT_MAX_PATHS","SITE_CHAT_MAX_PATH_LENGTH","SITE_CHAT_MESSAGE_MAX","SITE_CHAT_TURNS_PER_CONVERSATION","SITE_CHAT_HISTORY_TURNS","SITE_CHAT_DEFAULT_GREETING","SITE_CHAT_DEFAULT_SETTINGS","enabled","greeting","openingMessage","chips","capabilities","pages","paths","position","monthlyCreditCap","handOff","CAPABILITY_SET","clean","value","max","replace","trim","slice","normalizeSiteChatSettings","input","raw","greetingText","length","error","openingText","entry","Array","isArray","chip","includes","push","filter","capability","list","noun","maxPaths","maxLength","undefined","cap","Number","isFinite","Math","min","floor","settings","readStoredSiteChatSettings","stored","result","siteChatSliceForPage","path","pathUnknown","readSiteChatSlice","map","Boolean","SITE_CHAT_CREDITS_BY_PLAN","free","starter","pro","enterprise","siteChatPlanCredits","plan","siteChatOnPlan","siteChatCeiling","planCredits","ownerCap","SITE_CHAT_TURN_HOLD_CREDITS","SITE_CHAT_UNAVAILABLE_COPY","SITE_CHAT_BUSY_COPY","SITE_CHAT_CONVERSATION_LIMIT_COPY"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,qBAAqB,EACrBC,iBAAiB,QAEZ,4CAA2C;AAQlD;;;;;CAKC,GAED,kEAAkE,GAClE,OAAO,MAAMC,kBAAkB,eAAc;AAC7C,8DAA8D,GAC9D,OAAO,MAAMC,2BAA2B,wBAAuB;AAC/D,gEAAgE,GAChE,OAAO,MAAMC,gCAAgC,6BAA4B;AACzE,gEAAgE,GAChE,OAAO,MAAMC,0BAA0B,uBAAsB;AAE7D,uEAAuE,GACvE,OAAO,MAAMC,yBAAyB,uBAAsB;AAE5D,wDAAwD,GACxD,OAAO,MAAMC,uBAAuB,eAAc;AAClD,wCAAwC,GACxC,OAAO,MAAMC,sBAAsB,aAAY;AAC/C,kDAAkD,GAClD,OA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C,QAAQ;AACrC;AAEA;;;CAGC,GACD,OAAO,SAASE,gBACdC,WAAmB,EACnBC,QAAmC;IAEnC,MAAMJ,OAAOnB,KAAK3B,GAAG,CAAC,GAAG2B,KAAKE,KAAK,CAACJ,OAAOwB,gBAAgB;IAC3D,IAAIC,aAAa,QAAQA,aAAa3B,WAAW,OAAOuB;IACxD,OAAOnB,KAAKC,GAAG,CAACkB,MAAMnB,KAAK3B,GAAG,CAAC,GAAG2B,KAAKE,KAAK,CAACJ,OAAOyB,aAAa;AACnE;AAEA;;;;CAIC,GACD,OAAO,MAAMC,8BAA8B,GAAE;AAqD7C,4EAA4E,GAC5E,OAAO,MAAMC,6BACX,6FAA4F;AAC9F,OAAO,MAAMC,sBAAsB,6DAA4D;AAC/F,OAAO,MAAMC,oCACX,2EAA0E"}
package/src/lib/plugin.js CHANGED
@@ -28,6 +28,7 @@ import { lazyWidget } from "./lazy-widget.js";
28
28
  */ /** What a page shows while its code arrives. */ const PAGE_LOADING = createElement(LinearProgress, {
29
29
  'aria-label': 'Loading'
30
30
  });
31
+ const SiteChatCard = lazyWidget('SiteChatCard', ()=>import("./components/site-chat-card.component.js").then((m)=>m.SiteChatCard));
31
32
  const AiSaveAsComponent = lazyWidget('AiSaveAsComponent', ()=>import("./components/ai-save-as-component.component.js").then((m)=>m.AiSaveAsComponent));
32
33
  const AiGenerateSectionControl = lazyWidget('AiGenerateSectionControl', ()=>import("./components/besigner-ai-controls.component.js").then((m)=>m.AiGenerateSectionControl));
33
34
  const AiRewriteControl = lazyWidget('AiRewriteControl', ()=>import("./components/besigner-ai-controls.component.js").then((m)=>m.AiRewriteControl));
@@ -156,6 +157,15 @@ const AiJobsPage = lazyWidget('AiJobsPage', ()=>import("./components/ai-jobs-pag
156
157
  }
157
158
  ],
158
159
  widgets: [
160
+ // The AI chat on the published site (AGL-4250): its settings, figures
161
+ // and the visitors' conversations, on the site's Setup page. The card
162
+ // draws nothing for a workspace the release flag is off for.
163
+ {
164
+ slot: 'hostSettings',
165
+ widgetId: 'ai-site-chat-settings',
166
+ title: 'AI chat',
167
+ Component: SiteChatCard
168
+ },
159
169
  {
160
170
  slot: 'consoleDock',
161
171
  widgetId: 'ai-assist-dock',