@ezychat/web 0.1.73 → 0.1.76
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/dist-lib/chunks/{admin-CYW5ewdl.js → admin-CwS6ahLc.js} +1 -1
- package/dist-lib/chunks/{admin-BTzz29_M.js → admin-p6QRa2DG.js} +1 -1
- package/dist-lib/chunks/{inbox-BhNcoSW9.js → inbox-C9xTxE6Y.js} +122 -2
- package/dist-lib/chunks/{inbox-D0mcktjU.js → inbox-D-koJMyr.js} +122 -2
- package/dist-lib/ezychat-web.css +1 -1
- package/dist-lib/index.js +7572 -6283
- package/dist-lib/sw-routes.ts +90 -0
- package/dist-lib/sw.ts +40 -0
- package/dist-lib/types/admin/BusinessTemplateCard.d.ts +11 -3
- package/dist-lib/types/admin/business-templates-data.d.ts +117 -0
- package/dist-lib/types/admin/business-templates.d.ts +48 -93
- package/dist-lib/types/api/ai-groups.d.ts +22 -0
- package/dist-lib/types/api/ai-templates.d.ts +145 -0
- package/dist-lib/types/api/group-admin.d.ts +77 -0
- package/dist-lib/types/api/queries.d.ts +8 -1
- package/dist-lib/types/api/query-client.d.ts +3 -0
- package/dist-lib/types/api/query-persist.d.ts +43 -0
- package/dist-lib/types/api/socket.d.ts +8 -0
- package/dist-lib/types/api/voice.d.ts +2 -2
- package/dist-lib/types/auth/user-caches.d.ts +2 -0
- package/dist-lib/types/i18n/resources.d.ts +144 -0
- package/dist-lib/types/inbox/FixEnglish.d.ts +27 -0
- package/dist-lib/types/inbox/GroupAdmin.d.ts +16 -0
- package/dist-lib/types/inbox/GroupAdminDialogs.d.ts +23 -0
- package/dist-lib/types/inbox/GroupAdminShared.d.ts +60 -0
- package/dist-lib/types/inbox/ProfileImageContext.d.ts +1 -2
- package/dist-lib/types/sw-routes.d.ts +42 -0
- package/package.json +6 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Runtime caching rules of the service worker (sw.ts). Pure: no workbox import and no service
|
|
2
|
+
// worker globals, so the rules can be unit-tested and the page can share the cache names.
|
|
3
|
+
// Only contact photos and message files are kept; API JSON never goes through these caches.
|
|
4
|
+
|
|
5
|
+
/** Contact and group member photos. */
|
|
6
|
+
export const AVATAR_CACHE = 'ezy-avatars-v1';
|
|
7
|
+
/** Message files (`/api/media/:id`). */
|
|
8
|
+
export const MEDIA_CACHE = 'ezy-media-v1';
|
|
9
|
+
/** Every version of the per-user caches: removed on sign-out and when another user signs in. */
|
|
10
|
+
export const USER_CACHE_PREFIXES = ['ezy-avatars-', 'ezy-media-'] as const;
|
|
11
|
+
/** Message the page posts to the service worker to remove the per-user caches. */
|
|
12
|
+
export const CLEAR_USER_CACHES = 'clear-user-caches';
|
|
13
|
+
|
|
14
|
+
const DAY_SECONDS = 24 * 60 * 60;
|
|
15
|
+
export const AVATAR_LIMITS = { maxEntries: 1000, maxAgeSeconds: 7 * DAY_SECONDS };
|
|
16
|
+
export const MEDIA_LIMITS = { maxEntries: 300, maxAgeSeconds: 30 * DAY_SECONDS };
|
|
17
|
+
|
|
18
|
+
/** `/api/chats/:jid/avatar` and `/api/chats/:groupJid/members/:member/avatar`. */
|
|
19
|
+
const AVATAR_PATH = /^\/api\/chats\/[^/]+\/(?:members\/[^/]+\/)?avatar$/;
|
|
20
|
+
/** `/api/media/:id` only (not `…/redownload`). */
|
|
21
|
+
const MEDIA_PATH = /^\/api\/media\/[^/]+$/;
|
|
22
|
+
|
|
23
|
+
type RouteRequest = Pick<Request, 'method' | 'cache' | 'headers'>;
|
|
24
|
+
|
|
25
|
+
/** A same-origin GET that does not ask to skip caches (`fetch(…, { cache: 'no-store' })`). */
|
|
26
|
+
function cacheableGet(url: URL, request: RouteRequest, origin: string): boolean {
|
|
27
|
+
return (
|
|
28
|
+
url.origin === origin &&
|
|
29
|
+
request.method === 'GET' &&
|
|
30
|
+
request.cache !== 'no-store' &&
|
|
31
|
+
request.cache !== 'reload'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isAvatarRequest(url: URL, request: RouteRequest, origin: string): boolean {
|
|
36
|
+
return cacheableGet(url, request, origin) && AVATAR_PATH.test(url.pathname);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Byte-range requests (audio and video players) stay on the network: a cached whole file cannot
|
|
41
|
+
* answer them, and a partial (206) answer is never stored.
|
|
42
|
+
*/
|
|
43
|
+
export function isMediaRequest(url: URL, request: RouteRequest, origin: string): boolean {
|
|
44
|
+
return (
|
|
45
|
+
cacheableGet(url, request, origin) &&
|
|
46
|
+
MEDIA_PATH.test(url.pathname) &&
|
|
47
|
+
!request.headers.has('range')
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Workbox plugin: never store a response the server marked `no-store` (e.g. a flagged file). */
|
|
52
|
+
export const noStorePlugin = {
|
|
53
|
+
cacheWillUpdate: ({ response }: { response: Response }): Promise<Response | null> =>
|
|
54
|
+
Promise.resolve(
|
|
55
|
+
/(^|[\s,])no-store($|[\s,;])/i.test(response.headers.get('cache-control') ?? '')
|
|
56
|
+
? null
|
|
57
|
+
: response,
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Largest message file the phone keeps: one long video must not fill the phone's storage. */
|
|
62
|
+
export const MEDIA_MAX_BYTES = 20 * 1024 * 1024;
|
|
63
|
+
|
|
64
|
+
/** Workbox plugin for message files: never store one larger than MEDIA_MAX_BYTES. */
|
|
65
|
+
export const mediaSizePlugin = {
|
|
66
|
+
cacheWillUpdate: ({ response }: { response: Response }): Promise<Response | null> =>
|
|
67
|
+
Promise.resolve(
|
|
68
|
+
Number(response.headers.get('content-length') ?? 0) > MEDIA_MAX_BYTES ? null : response,
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export function isClearUserCachesMessage(data: unknown): boolean {
|
|
73
|
+
return (
|
|
74
|
+
typeof data === 'object' &&
|
|
75
|
+
data !== null &&
|
|
76
|
+
(data as { type?: unknown }).type === CLEAR_USER_CACHES
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function isUserCacheName(name: string): boolean {
|
|
81
|
+
return USER_CACHE_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Removes the photo and file caches; the app's own precache stays. */
|
|
85
|
+
export async function deleteUserCaches(
|
|
86
|
+
storage: Pick<CacheStorage, 'keys' | 'delete'>,
|
|
87
|
+
): Promise<void> {
|
|
88
|
+
const names = await storage.keys();
|
|
89
|
+
await Promise.all(names.filter(isUserCacheName).map((name) => storage.delete(name)));
|
|
90
|
+
}
|
package/dist-lib/sw.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
/// <reference lib="webworker" />
|
|
2
2
|
// Service worker (built by vite-plugin-pwa, strategies: 'injectManifest').
|
|
3
3
|
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
|
|
4
|
+
import { registerRoute } from 'workbox-routing';
|
|
5
|
+
import { CacheFirst } from 'workbox-strategies';
|
|
6
|
+
import { ExpirationPlugin } from 'workbox-expiration';
|
|
7
|
+
import { CacheableResponsePlugin } from 'workbox-cacheable-response';
|
|
8
|
+
import {
|
|
9
|
+
AVATAR_CACHE,
|
|
10
|
+
AVATAR_LIMITS,
|
|
11
|
+
MEDIA_CACHE,
|
|
12
|
+
MEDIA_LIMITS,
|
|
13
|
+
deleteUserCaches,
|
|
14
|
+
isAvatarRequest,
|
|
15
|
+
isClearUserCachesMessage,
|
|
16
|
+
isMediaRequest,
|
|
17
|
+
mediaSizePlugin,
|
|
18
|
+
noStorePlugin,
|
|
19
|
+
} from './sw-routes';
|
|
4
20
|
|
|
5
21
|
declare let self: ServiceWorkerGlobalScope & {
|
|
6
22
|
__WB_MANIFEST: Array<string | { url: string; revision: string | null }>;
|
|
@@ -17,6 +33,30 @@ interface PushPayload {
|
|
|
17
33
|
cleanupOutdatedCaches();
|
|
18
34
|
precacheAndRoute(self.__WB_MANIFEST);
|
|
19
35
|
|
|
36
|
+
// Contact photos and message files are kept on the device (rules in sw-routes.ts). API JSON is
|
|
37
|
+
// never cached here. Only full 200 answers are stored, never one marked no-store.
|
|
38
|
+
const keptAnswers = (limits: { maxEntries: number; maxAgeSeconds: number }) => [
|
|
39
|
+
noStorePlugin,
|
|
40
|
+
new CacheableResponsePlugin({ statuses: [200] }),
|
|
41
|
+
new ExpirationPlugin({ ...limits, purgeOnQuotaError: true }),
|
|
42
|
+
];
|
|
43
|
+
registerRoute(
|
|
44
|
+
({ url, request }) => isAvatarRequest(url, request, self.location.origin),
|
|
45
|
+
new CacheFirst({ cacheName: AVATAR_CACHE, plugins: keptAnswers(AVATAR_LIMITS) }),
|
|
46
|
+
);
|
|
47
|
+
registerRoute(
|
|
48
|
+
({ url, request }) => isMediaRequest(url, request, self.location.origin),
|
|
49
|
+
new CacheFirst({
|
|
50
|
+
cacheName: MEDIA_CACHE,
|
|
51
|
+
plugins: [mediaSizePlugin, ...keptAnswers(MEDIA_LIMITS)],
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Sign-out or another user signing in: the page asks to remove the photos and files.
|
|
56
|
+
self.addEventListener('message', (event) => {
|
|
57
|
+
if (isClearUserCachesMessage(event.data)) event.waitUntil(deleteUserCaches(self.caches));
|
|
58
|
+
});
|
|
59
|
+
|
|
20
60
|
// registerType 'autoUpdate': activate new versions immediately.
|
|
21
61
|
self.addEventListener('install', () => {
|
|
22
62
|
void self.skipWaiting();
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AgentTemplateCatalog } from '@ezychat/shared';
|
|
2
|
+
import { type GalleryTemplate } from './business-templates';
|
|
2
3
|
/**
|
|
3
4
|
* "Start from a business template": opens the template gallery. Apply fills the page's draft (the
|
|
4
5
|
* admin checks it and saves); `pendingItem` names the Business context item the next Save adds.
|
|
6
|
+
* `groupSetup` follows a group-agent template (Claims): what Save does for a new agent, or what the
|
|
7
|
+
* admin still switches on an existing one, then the remaining steps. `catalog` is the signed
|
|
8
|
+
* template list (none while loading or offline: the app's own templates show); `onBrowse` asks the
|
|
9
|
+
* server to check for new templates when the gallery opens.
|
|
5
10
|
*/
|
|
6
|
-
export declare function BusinessTemplateCard({ disabled, pendingItem, onApply, }: {
|
|
11
|
+
export declare function BusinessTemplateCard({ disabled, pendingItem, groupSetup, catalog, onBrowse, onApply, }: {
|
|
7
12
|
disabled: boolean;
|
|
8
13
|
pendingItem: string | null;
|
|
9
|
-
|
|
14
|
+
groupSetup?: 'new' | 'existing' | null;
|
|
15
|
+
catalog?: AgentTemplateCatalog;
|
|
16
|
+
onBrowse?: () => void;
|
|
17
|
+
onApply: (template: GalleryTemplate) => void;
|
|
10
18
|
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The templates built into this app (plain data, no React: `scripts/export-templates.mjs` reads it to
|
|
3
|
+
* write the publishing repo's `templates/` folder). Texts live in the catalogs
|
|
4
|
+
* (`ai.businessTemplates.<id>.*`). Each is version 1: a template of the signed template list
|
|
5
|
+
* replaces one only with a higher version (docs/features/template-store/design.md).
|
|
6
|
+
*/
|
|
7
|
+
export declare const TEMPLATE_CATEGORIES: readonly ["health", "food", "services", "shops", "education", "operations"];
|
|
8
|
+
export type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number];
|
|
9
|
+
/** `answerGroups` on and `answerDirect` off: an agent that works in WhatsApp groups only. */
|
|
10
|
+
export interface TemplateDefaults {
|
|
11
|
+
answerDirect?: boolean;
|
|
12
|
+
answerGroups?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const GROUP_AGENT_DEFAULTS: {
|
|
15
|
+
readonly answerGroups: true;
|
|
16
|
+
readonly answerDirect: false;
|
|
17
|
+
};
|
|
18
|
+
export declare const BUSINESS_TEMPLATES: readonly [{
|
|
19
|
+
readonly id: "clinic";
|
|
20
|
+
readonly preset: "faq";
|
|
21
|
+
readonly category: "health";
|
|
22
|
+
readonly icon: "stethoscope";
|
|
23
|
+
}, {
|
|
24
|
+
readonly id: "dental";
|
|
25
|
+
readonly preset: "faq";
|
|
26
|
+
readonly category: "health";
|
|
27
|
+
readonly icon: "smile";
|
|
28
|
+
}, {
|
|
29
|
+
readonly id: "salon";
|
|
30
|
+
readonly preset: "sales";
|
|
31
|
+
readonly category: "health";
|
|
32
|
+
readonly icon: "scissors";
|
|
33
|
+
}, {
|
|
34
|
+
readonly id: "gym";
|
|
35
|
+
readonly preset: "sales";
|
|
36
|
+
readonly category: "health";
|
|
37
|
+
readonly icon: "dumbbell";
|
|
38
|
+
}, {
|
|
39
|
+
readonly id: "vet";
|
|
40
|
+
readonly preset: "faq";
|
|
41
|
+
readonly category: "health";
|
|
42
|
+
readonly icon: "paw-print";
|
|
43
|
+
}, {
|
|
44
|
+
readonly id: "restaurant";
|
|
45
|
+
readonly preset: "sales";
|
|
46
|
+
readonly category: "food";
|
|
47
|
+
readonly icon: "utensils-crossed";
|
|
48
|
+
}, {
|
|
49
|
+
readonly id: "bakery";
|
|
50
|
+
readonly preset: "sales";
|
|
51
|
+
readonly category: "food";
|
|
52
|
+
readonly icon: "cake-slice";
|
|
53
|
+
}, {
|
|
54
|
+
readonly id: "catering";
|
|
55
|
+
readonly preset: "sales";
|
|
56
|
+
readonly category: "food";
|
|
57
|
+
readonly icon: "chef-hat";
|
|
58
|
+
}, {
|
|
59
|
+
readonly id: "carWorkshop";
|
|
60
|
+
readonly preset: "sales";
|
|
61
|
+
readonly category: "services";
|
|
62
|
+
readonly icon: "car";
|
|
63
|
+
}, {
|
|
64
|
+
readonly id: "homeServices";
|
|
65
|
+
readonly preset: "sales";
|
|
66
|
+
readonly category: "services";
|
|
67
|
+
readonly icon: "house";
|
|
68
|
+
}, {
|
|
69
|
+
readonly id: "property";
|
|
70
|
+
readonly preset: "sales";
|
|
71
|
+
readonly category: "services";
|
|
72
|
+
readonly icon: "building-2";
|
|
73
|
+
}, {
|
|
74
|
+
readonly id: "insurance";
|
|
75
|
+
readonly preset: "faq";
|
|
76
|
+
readonly category: "services";
|
|
77
|
+
readonly icon: "shield-check";
|
|
78
|
+
}, {
|
|
79
|
+
readonly id: "travel";
|
|
80
|
+
readonly preset: "sales";
|
|
81
|
+
readonly category: "services";
|
|
82
|
+
readonly icon: "plane";
|
|
83
|
+
}, {
|
|
84
|
+
readonly id: "onlineShop";
|
|
85
|
+
readonly preset: "sales";
|
|
86
|
+
readonly category: "shops";
|
|
87
|
+
readonly icon: "shopping-bag";
|
|
88
|
+
}, {
|
|
89
|
+
readonly id: "retail";
|
|
90
|
+
readonly preset: "sales";
|
|
91
|
+
readonly category: "shops";
|
|
92
|
+
readonly icon: "store";
|
|
93
|
+
}, {
|
|
94
|
+
readonly id: "phoneRepair";
|
|
95
|
+
readonly preset: "sales";
|
|
96
|
+
readonly category: "shops";
|
|
97
|
+
readonly icon: "smartphone";
|
|
98
|
+
}, {
|
|
99
|
+
readonly id: "tuition";
|
|
100
|
+
readonly preset: "sales";
|
|
101
|
+
readonly category: "education";
|
|
102
|
+
readonly icon: "graduation-cap";
|
|
103
|
+
}, {
|
|
104
|
+
readonly id: "claims";
|
|
105
|
+
readonly preset: "custom";
|
|
106
|
+
readonly category: "operations";
|
|
107
|
+
readonly icon: "receipt-text";
|
|
108
|
+
readonly defaults: {
|
|
109
|
+
readonly answerGroups: true;
|
|
110
|
+
readonly answerDirect: false;
|
|
111
|
+
};
|
|
112
|
+
}];
|
|
113
|
+
export type BusinessTemplateId = (typeof BUSINESS_TEMPLATES)[number]['id'];
|
|
114
|
+
/** The version of every built-in template (a list template replaces one only when higher). */
|
|
115
|
+
export declare const BUILTIN_TEMPLATE_VERSION = 1;
|
|
116
|
+
/** True for the group-only defaults (switched on a new agent; an existing one gets a note). */
|
|
117
|
+
export declare function isGroupAgent(defaults: TemplateDefaults | undefined): boolean;
|
|
@@ -1,111 +1,66 @@
|
|
|
1
1
|
import type { TFunction } from 'i18next';
|
|
2
2
|
import { type LucideIcon } from 'lucide-react';
|
|
3
|
-
import type
|
|
3
|
+
import { type AgentTemplateCatalog, type AgentTemplateText, type AiAgentPreset, type AiContextTextBody } from '@ezychat/shared';
|
|
4
|
+
export { BUSINESS_TEMPLATES, TEMPLATE_CATEGORIES, type BusinessTemplateId, type TemplateCategory, } from './business-templates-data';
|
|
4
5
|
/**
|
|
5
6
|
* Ready-made AI agents for common businesses. A template is the tested starting text of its agent
|
|
6
7
|
* type plus a short business part, its own hand-off rules and one Business context item of
|
|
7
8
|
* fill-in lines (a blank line gives the AI no fact, so it hands the chat over instead of guessing).
|
|
8
|
-
*
|
|
9
|
+
* The app's own templates read their texts from the catalogs (`ai.businessTemplates.<id>.*`); the
|
|
10
|
+
* signed template list (`GET /api/ai/templates`, docs/features/template-store/design.md) adds new
|
|
11
|
+
* ones and replaces one only with a higher version.
|
|
9
12
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
readonly id: "catering";
|
|
49
|
-
readonly preset: "sales";
|
|
50
|
-
readonly category: "food";
|
|
51
|
-
readonly icon: LucideIcon;
|
|
52
|
-
}, {
|
|
53
|
-
readonly id: "carWorkshop";
|
|
54
|
-
readonly preset: "sales";
|
|
55
|
-
readonly category: "services";
|
|
56
|
-
readonly icon: LucideIcon;
|
|
57
|
-
}, {
|
|
58
|
-
readonly id: "homeServices";
|
|
59
|
-
readonly preset: "sales";
|
|
60
|
-
readonly category: "services";
|
|
61
|
-
readonly icon: LucideIcon;
|
|
62
|
-
}, {
|
|
63
|
-
readonly id: "property";
|
|
64
|
-
readonly preset: "sales";
|
|
65
|
-
readonly category: "services";
|
|
66
|
-
readonly icon: LucideIcon;
|
|
67
|
-
}, {
|
|
68
|
-
readonly id: "insurance";
|
|
69
|
-
readonly preset: "faq";
|
|
70
|
-
readonly category: "services";
|
|
71
|
-
readonly icon: LucideIcon;
|
|
72
|
-
}, {
|
|
73
|
-
readonly id: "travel";
|
|
74
|
-
readonly preset: "sales";
|
|
75
|
-
readonly category: "services";
|
|
76
|
-
readonly icon: LucideIcon;
|
|
77
|
-
}, {
|
|
78
|
-
readonly id: "onlineShop";
|
|
79
|
-
readonly preset: "sales";
|
|
80
|
-
readonly category: "shops";
|
|
81
|
-
readonly icon: LucideIcon;
|
|
82
|
-
}, {
|
|
83
|
-
readonly id: "retail";
|
|
84
|
-
readonly preset: "sales";
|
|
85
|
-
readonly category: "shops";
|
|
86
|
-
readonly icon: LucideIcon;
|
|
87
|
-
}, {
|
|
88
|
-
readonly id: "phoneRepair";
|
|
89
|
-
readonly preset: "sales";
|
|
90
|
-
readonly category: "shops";
|
|
91
|
-
readonly icon: LucideIcon;
|
|
92
|
-
}, {
|
|
93
|
-
readonly id: "tuition";
|
|
94
|
-
readonly preset: "sales";
|
|
95
|
-
readonly category: "education";
|
|
96
|
-
readonly icon: LucideIcon;
|
|
97
|
-
}];
|
|
98
|
-
export type BusinessTemplateId = (typeof BUSINESS_TEMPLATES)[number]['id'];
|
|
13
|
+
/**
|
|
14
|
+
* The icons a template may name (bundled with the app: a list never sends an image). An unknown
|
|
15
|
+
* name shows `FALLBACK_ICON`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TEMPLATE_ICONS: Readonly<Record<string, LucideIcon>>;
|
|
18
|
+
export declare const FALLBACK_ICON: LucideIcon;
|
|
19
|
+
export declare const templateIcon: (name: string) => LucideIcon;
|
|
20
|
+
/** One template as the gallery shows it, in the admin's language, from either source. */
|
|
21
|
+
export interface GalleryTemplate {
|
|
22
|
+
id: string;
|
|
23
|
+
version: number;
|
|
24
|
+
/** `app`: built into this version; `list`: from the signed template list. */
|
|
25
|
+
source: 'app' | 'list';
|
|
26
|
+
preset: AiAgentPreset;
|
|
27
|
+
category: string;
|
|
28
|
+
icon: LucideIcon;
|
|
29
|
+
texts: AgentTemplateText;
|
|
30
|
+
/** Works in WhatsApp groups only (switched on a new agent; an existing one gets a note). */
|
|
31
|
+
groupAgent: boolean;
|
|
32
|
+
/** Names of the connectors the template recommends (list templates only). */
|
|
33
|
+
connectors: string[];
|
|
34
|
+
}
|
|
35
|
+
/** The app's own templates, texts from the catalogs. */
|
|
36
|
+
export declare function builtinTemplates(t: TFunction<'admin'>): GalleryTemplate[];
|
|
37
|
+
/**
|
|
38
|
+
* The gallery: the app's own templates, each replaced by a list template with the same id only when
|
|
39
|
+
* the list's version is higher, then the list's new templates. Without a list (loading, offline,
|
|
40
|
+
* an error) the app's own templates show.
|
|
41
|
+
*/
|
|
42
|
+
export declare function galleryTemplates(t: TFunction<'admin'>, language: string, catalog: AgentTemplateCatalog | undefined): GalleryTemplate[];
|
|
43
|
+
/**
|
|
44
|
+
* The category chips: the app's own (catalog names), then categories only the list defines and a
|
|
45
|
+
* shown template uses (the list's name for them).
|
|
46
|
+
*/
|
|
47
|
+
export declare function galleryCategories(t: TFunction<'admin'>, language: string, catalog: AgentTemplateCatalog | undefined, templates: readonly GalleryTemplate[]): Array<{
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
}>;
|
|
99
51
|
export interface BusinessTemplateTexts {
|
|
100
52
|
preset: AiAgentPreset;
|
|
101
53
|
agentName: string;
|
|
102
54
|
instructions: string;
|
|
103
55
|
handoffRules: string;
|
|
104
56
|
contextItem: AiContextTextBody;
|
|
57
|
+
/** Works in WhatsApp groups only. */
|
|
58
|
+
groupAgent: boolean;
|
|
105
59
|
}
|
|
106
|
-
|
|
60
|
+
/** What Apply puts in the editor: the agent type's starting text, then the business part. */
|
|
61
|
+
export declare function businessTemplate(tpl: GalleryTemplate, t: TFunction<'admin'>): BusinessTemplateTexts;
|
|
107
62
|
/**
|
|
108
63
|
* True when every word of `query` appears in the template's name, description or search words
|
|
109
64
|
* (the catalogs keep English words beside the translated ones, so either language finds it).
|
|
110
65
|
*/
|
|
111
|
-
export declare function templateMatches(
|
|
66
|
+
export declare function templateMatches(tpl: GalleryTemplate, query: string): boolean;
|
|
@@ -123,3 +123,25 @@ export declare function useSetGroupChatAi(): import("@tanstack/react-query").Use
|
|
|
123
123
|
} & {
|
|
124
124
|
jid: string;
|
|
125
125
|
}, unknown>;
|
|
126
|
+
/**
|
|
127
|
+
* Makes a newly created agent a group agent (a template such as Claims): Answer in groups on, then
|
|
128
|
+
* Answer direct chats off. Only for an agent that holds no chats yet, so nothing is released.
|
|
129
|
+
*/
|
|
130
|
+
export declare function useMakeGroupAgent(): import("@tanstack/react-query").UseMutationResult<{
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
inboxName: string | null;
|
|
133
|
+
groups: {
|
|
134
|
+
jid: string;
|
|
135
|
+
name: string;
|
|
136
|
+
memberCount: number | null;
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
paused: boolean;
|
|
139
|
+
agentId: number | null;
|
|
140
|
+
agentName: string | null;
|
|
141
|
+
listen: boolean;
|
|
142
|
+
}[];
|
|
143
|
+
loopGuard: number;
|
|
144
|
+
answerDirect: boolean;
|
|
145
|
+
directAvailable: boolean;
|
|
146
|
+
heldDirect: number;
|
|
147
|
+
}, Error, number, unknown>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI agent templates from the signed template list (docs/features/template-store/design.md),
|
|
3
|
+
* admins only. The gallery falls back to the app's own templates while these load or fail.
|
|
4
|
+
*/
|
|
5
|
+
export declare const templateCatalogKey: readonly ["ai", "templates"];
|
|
6
|
+
/** The list as the server keeps it (no download). */
|
|
7
|
+
export declare function useTemplateCatalog(enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
8
|
+
status: {
|
|
9
|
+
state: "offline" | "loaded" | "rejected" | "builtin";
|
|
10
|
+
generatedAt: string | null;
|
|
11
|
+
sequence: number | null;
|
|
12
|
+
checkedAt: number | null;
|
|
13
|
+
};
|
|
14
|
+
categories: {
|
|
15
|
+
id: string;
|
|
16
|
+
name: {
|
|
17
|
+
en: string;
|
|
18
|
+
ms?: string | undefined;
|
|
19
|
+
'zh-CN'?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
}[];
|
|
22
|
+
templates: {
|
|
23
|
+
entry: {
|
|
24
|
+
id: string;
|
|
25
|
+
version: number;
|
|
26
|
+
schemaVersion: 1;
|
|
27
|
+
minAppVersion: string;
|
|
28
|
+
editions: ("lite" | "enterprise")[];
|
|
29
|
+
category: string;
|
|
30
|
+
icon: string;
|
|
31
|
+
preset: "sales" | "custom" | "faq";
|
|
32
|
+
texts: {
|
|
33
|
+
en: {
|
|
34
|
+
agentName: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
keywords: string;
|
|
38
|
+
focus: string;
|
|
39
|
+
handoffRules: string;
|
|
40
|
+
contextName: string;
|
|
41
|
+
contextText: string;
|
|
42
|
+
};
|
|
43
|
+
ms?: {
|
|
44
|
+
agentName: string;
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
keywords: string;
|
|
48
|
+
focus: string;
|
|
49
|
+
handoffRules: string;
|
|
50
|
+
contextName: string;
|
|
51
|
+
contextText: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
'zh-CN'?: {
|
|
54
|
+
agentName: string;
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
keywords: string;
|
|
58
|
+
focus: string;
|
|
59
|
+
handoffRules: string;
|
|
60
|
+
contextName: string;
|
|
61
|
+
contextText: string;
|
|
62
|
+
} | undefined;
|
|
63
|
+
};
|
|
64
|
+
defaults?: {
|
|
65
|
+
answerDirect?: boolean | undefined;
|
|
66
|
+
answerGroups?: boolean | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
recommendedConnectors?: string[] | undefined;
|
|
69
|
+
};
|
|
70
|
+
connectors: {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
}[];
|
|
74
|
+
}[];
|
|
75
|
+
}, Error>;
|
|
76
|
+
/** Downloads and checks the list now (the gallery opens). */
|
|
77
|
+
export declare function useRefreshTemplates(): import("@tanstack/react-query").UseMutationResult<{
|
|
78
|
+
status: {
|
|
79
|
+
state: "offline" | "loaded" | "rejected" | "builtin";
|
|
80
|
+
generatedAt: string | null;
|
|
81
|
+
sequence: number | null;
|
|
82
|
+
checkedAt: number | null;
|
|
83
|
+
};
|
|
84
|
+
categories: {
|
|
85
|
+
id: string;
|
|
86
|
+
name: {
|
|
87
|
+
en: string;
|
|
88
|
+
ms?: string | undefined;
|
|
89
|
+
'zh-CN'?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
}[];
|
|
92
|
+
templates: {
|
|
93
|
+
entry: {
|
|
94
|
+
id: string;
|
|
95
|
+
version: number;
|
|
96
|
+
schemaVersion: 1;
|
|
97
|
+
minAppVersion: string;
|
|
98
|
+
editions: ("lite" | "enterprise")[];
|
|
99
|
+
category: string;
|
|
100
|
+
icon: string;
|
|
101
|
+
preset: "sales" | "custom" | "faq";
|
|
102
|
+
texts: {
|
|
103
|
+
en: {
|
|
104
|
+
agentName: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
keywords: string;
|
|
108
|
+
focus: string;
|
|
109
|
+
handoffRules: string;
|
|
110
|
+
contextName: string;
|
|
111
|
+
contextText: string;
|
|
112
|
+
};
|
|
113
|
+
ms?: {
|
|
114
|
+
agentName: string;
|
|
115
|
+
name: string;
|
|
116
|
+
description: string;
|
|
117
|
+
keywords: string;
|
|
118
|
+
focus: string;
|
|
119
|
+
handoffRules: string;
|
|
120
|
+
contextName: string;
|
|
121
|
+
contextText: string;
|
|
122
|
+
} | undefined;
|
|
123
|
+
'zh-CN'?: {
|
|
124
|
+
agentName: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
keywords: string;
|
|
128
|
+
focus: string;
|
|
129
|
+
handoffRules: string;
|
|
130
|
+
contextName: string;
|
|
131
|
+
contextText: string;
|
|
132
|
+
} | undefined;
|
|
133
|
+
};
|
|
134
|
+
defaults?: {
|
|
135
|
+
answerDirect?: boolean | undefined;
|
|
136
|
+
answerGroups?: boolean | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
recommendedConnectors?: string[] | undefined;
|
|
139
|
+
};
|
|
140
|
+
connectors: {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
}[];
|
|
144
|
+
}[];
|
|
145
|
+
}, Error, void, unknown>;
|