@ezychat/web 0.1.73 → 0.1.75

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.
@@ -1,10 +1,18 @@
1
- import { type BusinessTemplateId } from './business-templates';
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
- onApply: (id: BusinessTemplateId) => void;
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 { AiAgentPreset, AiContextTextBody } from '@ezychat/shared';
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
- * Texts live in the catalogs (`ai.businessTemplates.<id>.*`), so each language gets its own copy.
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
- export declare const TEMPLATE_CATEGORIES: readonly ["health", "food", "services", "shops", "education"];
11
- export type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number];
12
- export declare const BUSINESS_TEMPLATES: readonly [{
13
- readonly id: "clinic";
14
- readonly preset: "faq";
15
- readonly category: "health";
16
- readonly icon: LucideIcon;
17
- }, {
18
- readonly id: "dental";
19
- readonly preset: "faq";
20
- readonly category: "health";
21
- readonly icon: LucideIcon;
22
- }, {
23
- readonly id: "salon";
24
- readonly preset: "sales";
25
- readonly category: "health";
26
- readonly icon: LucideIcon;
27
- }, {
28
- readonly id: "gym";
29
- readonly preset: "sales";
30
- readonly category: "health";
31
- readonly icon: LucideIcon;
32
- }, {
33
- readonly id: "vet";
34
- readonly preset: "faq";
35
- readonly category: "health";
36
- readonly icon: LucideIcon;
37
- }, {
38
- readonly id: "restaurant";
39
- readonly preset: "sales";
40
- readonly category: "food";
41
- readonly icon: LucideIcon;
42
- }, {
43
- readonly id: "bakery";
44
- readonly preset: "sales";
45
- readonly category: "food";
46
- readonly icon: LucideIcon;
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
- export declare function businessTemplate(id: BusinessTemplateId, t: TFunction<'admin'>): BusinessTemplateTexts;
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(id: BusinessTemplateId, query: string, t: TFunction<'admin'>): boolean;
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>;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Group management (design docs/features/group-management/design.md): what an EzyChat admin may
3
+ * change in a WhatsApp group from Group info. The answer carries the connection's `caps`; the UI
4
+ * shows only those actions, never by inbox type. Changes are never queued (offline → 503).
5
+ */
6
+ export declare const groupAdminKey: (jid: string) => readonly ["group-admin", string];
7
+ export declare function useGroupAdmin(jid: string, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
8
+ caps: {
9
+ editInfo: boolean;
10
+ addMembers: boolean;
11
+ inviteOnly: boolean;
12
+ removeMembers: boolean;
13
+ admins: boolean;
14
+ inviteLink: boolean;
15
+ resetInviteLink: boolean;
16
+ settings: ("locked" | "announce" | "memberAdd" | "approval")[];
17
+ joinRequests: boolean;
18
+ maxMembers: number | null;
19
+ nameMax: number;
20
+ descriptionMax: number;
21
+ };
22
+ canManage: boolean;
23
+ online: boolean;
24
+ myRole: "admin" | "member" | "superadmin" | null;
25
+ settings: {
26
+ announce?: boolean | undefined;
27
+ locked?: boolean | undefined;
28
+ memberAdd?: "all" | "admins" | undefined;
29
+ approval?: boolean | undefined;
30
+ };
31
+ inviteLink: string | null;
32
+ requests: {
33
+ jid: string;
34
+ phone: string | null;
35
+ name: string | null;
36
+ at: number | null;
37
+ }[];
38
+ changes: {
39
+ at: number;
40
+ byUserId: number | null;
41
+ byName: string | null;
42
+ action: "description" | "setting" | "rename" | "member_add" | "member_invite" | "member_remove" | "admin_promote" | "admin_demote" | "invite_reset" | "join_approve" | "join_reject";
43
+ memberJid: string | null;
44
+ memberName: string | null;
45
+ setting: "locked" | "announce" | "memberAdd" | "approval" | null;
46
+ value: boolean | "all" | "admins" | null;
47
+ }[];
48
+ size: number | null;
49
+ }, Error>;
50
+ export declare const useEditGroup: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
51
+ name?: string | undefined;
52
+ description?: string | undefined;
53
+ }, unknown>;
54
+ /** Exactly one number (digits with country code). `invite_needed`: offer Send invite. */
55
+ export declare const useAddGroupMember: (jid: string) => import("@tanstack/react-query").UseMutationResult<{
56
+ result: "added" | "invite_needed";
57
+ memberJid: string;
58
+ }, Error, string, unknown>;
59
+ export declare const useSendGroupInvite: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
60
+ export declare const useRemoveGroupMember: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
61
+ export declare const useSetGroupMemberAdmin: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
62
+ member: string;
63
+ admin: boolean;
64
+ }, unknown>;
65
+ export declare function useResetGroupInvite(jid: string): import("@tanstack/react-query").UseMutationResult<{
66
+ inviteLink: string;
67
+ }, Error, unknown, unknown>;
68
+ export declare function useGroupSettings(jid: string): import("@tanstack/react-query").UseMutationResult<unknown, Error, Partial<{
69
+ announce: boolean;
70
+ locked: boolean;
71
+ memberAdd: "all" | "admins";
72
+ approval: boolean;
73
+ }>, unknown>;
74
+ export declare const useGroupJoinRequest: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
75
+ member: string;
76
+ approve: boolean;
77
+ }, unknown>;