@ezychat/web 0.1.78 → 0.1.79

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 (28) hide show
  1. package/dist-lib/chunks/{admin-Bw0RmdAy.js → admin-D4nMrYTV.js} +48 -5
  2. package/dist-lib/chunks/{admin-Vk_4QCBI.js → admin-SGy97Cay.js} +46 -5
  3. package/dist-lib/chunks/{inbox-BP7OELj9.js → inbox-RAdHANUD.js} +89 -5
  4. package/dist-lib/chunks/{inbox-g6IVD36a.js → inbox-iUbtLuDB.js} +89 -5
  5. package/dist-lib/ezychat-web.css +1 -1
  6. package/dist-lib/index.js +8253 -6510
  7. package/dist-lib/public/badge-96.png +0 -0
  8. package/dist-lib/sw.ts +2 -1
  9. package/dist-lib/types/admin/AgentScheduledTasksCard.d.ts +10 -0
  10. package/dist-lib/types/admin/MemberChatsField.d.ts +11 -0
  11. package/dist-lib/types/admin/NewChatSection.d.ts +7 -0
  12. package/dist-lib/types/admin/ScheduledRunsDialog.d.ts +12 -0
  13. package/dist-lib/types/admin/ScheduledTaskDialog.d.ts +18 -0
  14. package/dist-lib/types/admin/scheduled-format.d.ts +16 -0
  15. package/dist-lib/types/api/ai.d.ts +5 -1
  16. package/dist-lib/types/api/inbox-mutations.d.ts +2 -0
  17. package/dist-lib/types/api/message-changes.d.ts +10 -2
  18. package/dist-lib/types/api/new-chat.d.ts +55 -0
  19. package/dist-lib/types/api/queries.d.ts +61 -8
  20. package/dist-lib/types/api/scheduled-tasks.d.ts +145 -0
  21. package/dist-lib/types/api/templates.d.ts +5 -1
  22. package/dist-lib/types/askezy/AskEzyButton.d.ts +1 -1
  23. package/dist-lib/types/auth/chat-scope.d.ts +7 -0
  24. package/dist-lib/types/i18n/resources.d.ts +244 -0
  25. package/dist-lib/types/inbox/NewChatDialog.d.ts +2 -0
  26. package/dist-lib/types/inbox/ReplyWindow.d.ts +16 -0
  27. package/dist-lib/types/inbox/useDirectory.d.ts +3 -0
  28. package/package.json +2 -2
Binary file
package/dist-lib/sw.ts CHANGED
@@ -77,7 +77,8 @@ self.addEventListener('push', (event) => {
77
77
  body: data.body ?? '',
78
78
  tag: data.tag,
79
79
  icon: '/icon-192.png',
80
- badge: '/icon-192.png',
80
+ // Android draws the badge from its alpha only: a full-colour icon becomes a white square.
81
+ badge: '/badge-96.png',
81
82
  data: { url: data.url ?? '/' },
82
83
  };
83
84
  event.waitUntil(self.registration.showNotification(title, options));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Agent page → Scheduled tasks (design docs/features/scheduled-tasks/design.md): each task makes
3
+ * this agent send one message at a set time to one existing chat or group of its inbox, or nothing
4
+ * when there is nothing to tell. Paused while the agent is off, the AI or WhatsApp is not connected
5
+ * or the app is locked. Admins only.
6
+ */
7
+ export declare function AgentScheduledTasksCard({ agentId, name, }: Readonly<{
8
+ agentId: number;
9
+ name: string;
10
+ }>): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { type MemberChat } from '@ezychat/shared';
2
+ /**
3
+ * "Chats this member can see" in Edit member, for agents only (design docs/features/partner-role):
4
+ * All chats (default, as today) or Only chosen chats, with the chosen list and a search to add more.
5
+ * The dialog saves it with `PUT /api/users/:id/chats`.
6
+ */
7
+ export declare function MemberChatsField({ scope, chats, onChange, }: {
8
+ scope: 'all' | 'chosen';
9
+ chats: MemberChat[];
10
+ onChange(scope: 'all' | 'chosen', chats: MemberChat[]): void;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Settings → General → New chats (docs/features/new-chat/design.md): admins can always start a chat with
3
+ * a new number; the switch lets team members do it too (off by default). The daily limit per linked
4
+ * WhatsApp number is the admin's choice (default 20, 0 = no limit), shared with AI assistants (MCP).
5
+ * Each change is audited with before/after.
6
+ */
7
+ export declare function NewChatSection(): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { type ScheduledRun, type ScheduledTask } from '@ezychat/shared';
2
+ /** A run's result as a small badge (a run still going has no result yet). */
3
+ export declare function RunResultBadge({ run }: Readonly<{
4
+ run: Pick<ScheduledRun, 'result'>;
5
+ }>): import("react").JSX.Element;
6
+ /** History: the task's last runs, newest first, with why one sent nothing and a link to the chat. */
7
+ export declare function ScheduledRunsDialog({ agentId, task, timeZone, onClose, }: Readonly<{
8
+ agentId: number;
9
+ task: ScheduledTask;
10
+ timeZone: string;
11
+ onClose: () => void;
12
+ }>): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { type ScheduledTask, type ScheduledTaskChat } from '@ezychat/shared';
2
+ export declare function ChatIcon({ type, className, }: Readonly<{
3
+ type: ScheduledTaskChat['type'];
4
+ className?: string;
5
+ }>): import("react").JSX.Element;
6
+ /**
7
+ * Add or edit a scheduled task: name, Send to (one existing chat or group of the agent's inbox),
8
+ * time and days in the business time zone, the instruction, and Preview (one turn, nothing sent).
9
+ */
10
+ export declare function ScheduledTaskDialog({ agentId, agentName, task, inboxId, timeZone, max, onClose, }: Readonly<{
11
+ agentId: number;
12
+ agentName: string;
13
+ task: ScheduledTask | null;
14
+ inboxId: number;
15
+ timeZone: string;
16
+ max: number;
17
+ onClose: () => void;
18
+ }>): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { type ScheduledTask } from '@ezychat/shared';
2
+ /** Monday first, as the business week reads. */
3
+ export declare const WEEK: readonly [1, 2, 3, 4, 5, 6, 0];
4
+ /** Rows the card shows before "Show all". */
5
+ export declare const FOLDED_ROWS = 5;
6
+ /**
7
+ * Dates and times of scheduled tasks in the page's language. Task times are wall-clock times of the
8
+ * business time zone (`timeZone`), so run times are shown in that zone too; an unknown zone falls
9
+ * back to the device's own.
10
+ */
11
+ export declare function useScheduledFormat(timeZone: string): {
12
+ time: (hhmm: string) => string;
13
+ when: (ms: number) => string;
14
+ day: (d: number) => string;
15
+ schedule: (task: Pick<ScheduledTask, "dayRule" | "days" | "time">) => string;
16
+ };
@@ -17,6 +17,8 @@ export declare function useAiMember(): import("@tanstack/react-query").UseQueryR
17
17
  aiAgentId?: number | undefined;
18
18
  aiDeleted?: boolean | undefined;
19
19
  inboxIds?: number[] | undefined;
20
+ chatScope?: "all" | "chosen" | undefined;
21
+ chatJids?: string[] | undefined;
20
22
  } | null;
21
23
  settings: {
22
24
  enabled: boolean;
@@ -95,7 +97,7 @@ export declare function useAiTry(): import("@tanstack/react-query").UseMutationR
95
97
  action: "handoff" | "answer" | "ask_resolution" | "resolve" | "no_reply" | null;
96
98
  model: string | null;
97
99
  error: string | null;
98
- handoffReason?: "asked_for_human" | "missing_facts" | "sensitive" | "needs_action" | "business_rule" | "unsupported_message" | "ai_unavailable" | "lookup_failed" | "confidential_leak" | "window_closed" | null | undefined;
100
+ handoffReason?: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "asked_for_human" | "missing_facts" | "sensitive" | "needs_action" | "business_rule" | "unsupported_message" | null | undefined;
99
101
  lookups?: {
100
102
  title: string;
101
103
  sourceLabel: string;
@@ -195,6 +197,8 @@ export declare function useAiMemberAction(): import("@tanstack/react-query").Use
195
197
  aiAgentId?: number | undefined;
196
198
  aiDeleted?: boolean | undefined;
197
199
  inboxIds?: number[] | undefined;
200
+ chatScope?: "all" | "chosen" | undefined;
201
+ chatJids?: string[] | undefined;
198
202
  } | null;
199
203
  settings: {
200
204
  enabled: boolean;
@@ -93,4 +93,6 @@ export declare function useSetUserInboxes(userId: number): import("@tanstack/rea
93
93
  aiAgentId?: number | undefined;
94
94
  aiDeleted?: boolean | undefined;
95
95
  inboxIds?: number[] | undefined;
96
+ chatScope?: "all" | "chosen" | undefined;
97
+ chatJids?: string[] | undefined;
96
98
  }, Error, number[], unknown>;
@@ -46,9 +46,13 @@ export declare function useEditMessage(): import("@tanstack/react-query").UseMut
46
46
  language: string;
47
47
  } | null | undefined;
48
48
  viaAssistant?: boolean | undefined;
49
+ scheduledTask?: {
50
+ id: number;
51
+ name: string | null;
52
+ } | null | undefined;
49
53
  transcript?: string | null | undefined;
50
54
  transcriptLang?: string | null | undefined;
51
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
55
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
52
56
  senderProfile?: {
53
57
  chatJid: string;
54
58
  name: string;
@@ -104,9 +108,13 @@ export declare function useDeleteMessage(): import("@tanstack/react-query").UseM
104
108
  language: string;
105
109
  } | null | undefined;
106
110
  viaAssistant?: boolean | undefined;
111
+ scheduledTask?: {
112
+ id: number;
113
+ name: string | null;
114
+ } | null | undefined;
107
115
  transcript?: string | null | undefined;
108
116
  transcriptLang?: string | null | undefined;
109
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
117
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
110
118
  senderProfile?: {
111
119
  chatJid: string;
112
120
  name: string;
@@ -0,0 +1,55 @@
1
+ import type { NewChatBodyInput } from '@ezychat/shared';
2
+ /** New chat (docs/features/new-chat/design.md). */
3
+ export declare const newChatKey: readonly ["new-chat"];
4
+ /** May the signed-in user start new chats, from which inboxes, and the team's settings. */
5
+ export declare function useNewChatStatus(enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
6
+ allowed: boolean;
7
+ staffEnabled: boolean;
8
+ dailyLimit: number;
9
+ perUserPerHour: number;
10
+ inboxes: {
11
+ inboxId: number;
12
+ mode: "template" | "unsupported" | "check";
13
+ usedToday: number;
14
+ countryCode: string;
15
+ }[];
16
+ }, Error>;
17
+ /** Admins: the team-members switch and the daily limit (each audited before/after). */
18
+ export declare function useUpdateNewChatSettings(): import("@tanstack/react-query").UseMutationResult<{
19
+ allowed: boolean;
20
+ staffEnabled: boolean;
21
+ dailyLimit: number;
22
+ perUserPerHour: number;
23
+ inboxes: {
24
+ inboxId: number;
25
+ mode: "template" | "unsupported" | "check";
26
+ usedToday: number;
27
+ countryCode: string;
28
+ }[];
29
+ }, Error, {
30
+ staffEnabled?: boolean | undefined;
31
+ dailyLimit?: number | undefined;
32
+ }, unknown>;
33
+ /** Format, own number and an existing chat: never asks WhatsApp, not counted. */
34
+ export declare function useCheckNewChat(): import("@tanstack/react-query").UseMutationResult<{
35
+ next: "existing";
36
+ phone: string;
37
+ chatJid: string;
38
+ } | {
39
+ next: "check";
40
+ phone: string;
41
+ } | {
42
+ next: "template";
43
+ phone: string;
44
+ }, Error, {
45
+ inboxId: number;
46
+ phone: string;
47
+ }, unknown>;
48
+ /** Start: checks the number on WhatsApp, or sends the first template (Business API). */
49
+ export declare function useStartNewChat(): import("@tanstack/react-query").UseMutationResult<{
50
+ chatJid: string;
51
+ created: boolean;
52
+ }, Error, {
53
+ inboxId: number;
54
+ body: NewChatBodyInput;
55
+ }, unknown>;
@@ -1,5 +1,5 @@
1
1
  import { type InfiniteData, type QueryClient } from '@tanstack/react-query';
2
- import { type ReportPeriod, type CreateApiTokenBodyInput, type UpdateApiTokenBody, type Chat, type ChatListResponse, type ChatStatus, type DirectoryUser, type InboxStatusPayload, type Message, type MessageListResponse, type MessageLocateResponse, type PatchUserBody, type Settings, type WaStatus } from '@ezychat/shared';
2
+ import { type ReportPeriod, type CreateApiTokenBodyInput, type UpdateApiTokenBody, type Chat, type ChatListResponse, type ChatStatus, type DirectoryUser, type InboxStatusPayload, type SetMemberChatsBody, type Message, type MessageListResponse, type MessageLocateResponse, type PatchUserBody, type Settings, type WaStatus } from '@ezychat/shared';
3
3
  export interface ChatFilters {
4
4
  status?: ChatStatus;
5
5
  assigned: 'me' | 'none' | 'any';
@@ -26,6 +26,7 @@ export declare const qk: {
26
26
  quickReplies: readonly ["quick-replies"];
27
27
  users: readonly ["users"];
28
28
  directory: readonly ["users", "directory"];
29
+ memberChats: (userId: number) => readonly ["users", number, "chats"];
29
30
  wa: readonly ["wa"];
30
31
  inboxes: readonly ["inboxes"];
31
32
  tunnel: readonly ["tunnel"];
@@ -72,6 +73,8 @@ export declare function useMe(): import("@tanstack/react-query").UseQueryResult<
72
73
  aiAgentId?: number | undefined;
73
74
  aiDeleted?: boolean | undefined;
74
75
  inboxIds?: number[] | undefined;
76
+ chatScope?: "all" | "chosen" | undefined;
77
+ chatJids?: string[] | undefined;
75
78
  } | null, Error>;
76
79
  export declare function useSetupStatus(): import("@tanstack/react-query").UseQueryResult<{
77
80
  needsSetup: boolean;
@@ -96,6 +99,8 @@ export declare function useLogin(): import("@tanstack/react-query").UseMutationR
96
99
  aiAgentId?: number | undefined;
97
100
  aiDeleted?: boolean | undefined;
98
101
  inboxIds?: number[] | undefined;
102
+ chatScope?: "all" | "chosen" | undefined;
103
+ chatJids?: string[] | undefined;
99
104
  } | null, Error, {
100
105
  username: string;
101
106
  password: string;
@@ -121,6 +126,8 @@ export declare function useSetMyLocale(): import("@tanstack/react-query").UseMut
121
126
  aiAgentId?: number | undefined;
122
127
  aiDeleted?: boolean | undefined;
123
128
  inboxIds?: number[] | undefined;
129
+ chatScope?: "all" | "chosen" | undefined;
130
+ chatJids?: string[] | undefined;
124
131
  }, Error, "en" | "ms" | "zh-CN" | null, unknown>;
125
132
  export declare function useChangePassword(): import("@tanstack/react-query").UseMutationResult<unknown, Error, {
126
133
  currentPassword: string;
@@ -138,7 +145,7 @@ export declare function useChats(filters: ChatFilters, opts?: {
138
145
  jid: string;
139
146
  inboxId: number;
140
147
  waJid: string;
141
- type: "group" | "dm";
148
+ type: "dm" | "group";
142
149
  name: string;
143
150
  avatarUrl: string | null;
144
151
  unreadCount: number;
@@ -159,7 +166,7 @@ export declare function useChat(jid: string | null | undefined): import("@tansta
159
166
  jid: string;
160
167
  inboxId: number;
161
168
  waJid: string;
162
- type: "group" | "dm";
169
+ type: "dm" | "group";
163
170
  name: string;
164
171
  avatarUrl: string | null;
165
172
  unreadCount: number;
@@ -282,9 +289,13 @@ export declare function useMessages(jid: string | null | undefined): import("@ta
282
289
  language: string;
283
290
  } | null | undefined;
284
291
  viaAssistant?: boolean | undefined;
292
+ scheduledTask?: {
293
+ id: number;
294
+ name: string | null;
295
+ } | null | undefined;
285
296
  transcript?: string | null | undefined;
286
297
  transcriptLang?: string | null | undefined;
287
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
298
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
288
299
  senderProfile?: {
289
300
  chatJid: string;
290
301
  name: string;
@@ -354,9 +365,13 @@ export declare function useSendText(jid: string): import("@tanstack/react-query"
354
365
  language: string;
355
366
  } | null | undefined;
356
367
  viaAssistant?: boolean | undefined;
368
+ scheduledTask?: {
369
+ id: number;
370
+ name: string | null;
371
+ } | null | undefined;
357
372
  transcript?: string | null | undefined;
358
373
  transcriptLang?: string | null | undefined;
359
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
374
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
360
375
  senderProfile?: {
361
376
  chatJid: string;
362
377
  name: string;
@@ -420,9 +435,13 @@ export declare function useSendMedia(jid: string): import("@tanstack/react-query
420
435
  language: string;
421
436
  } | null | undefined;
422
437
  viaAssistant?: boolean | undefined;
438
+ scheduledTask?: {
439
+ id: number;
440
+ name: string | null;
441
+ } | null | undefined;
423
442
  transcript?: string | null | undefined;
424
443
  transcriptLang?: string | null | undefined;
425
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
444
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
426
445
  senderProfile?: {
427
446
  chatJid: string;
428
447
  name: string;
@@ -475,9 +494,13 @@ export declare function useRetryMessage(): import("@tanstack/react-query").UseMu
475
494
  language: string;
476
495
  } | null | undefined;
477
496
  viaAssistant?: boolean | undefined;
497
+ scheduledTask?: {
498
+ id: number;
499
+ name: string | null;
500
+ } | null | undefined;
478
501
  transcript?: string | null | undefined;
479
502
  transcriptLang?: string | null | undefined;
480
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
503
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
481
504
  senderProfile?: {
482
505
  chatJid: string;
483
506
  name: string;
@@ -521,7 +544,7 @@ export declare function usePatchChat(jid: string): import("@tanstack/react-query
521
544
  jid: string;
522
545
  inboxId: number;
523
546
  waJid: string;
524
- type: "group" | "dm";
547
+ type: "dm" | "group";
525
548
  name: string;
526
549
  avatarUrl: string | null;
527
550
  unreadCount: number;
@@ -673,6 +696,8 @@ export declare function useUsers(opts?: {
673
696
  aiAgentId?: number | undefined;
674
697
  aiDeleted?: boolean | undefined;
675
698
  inboxIds?: number[] | undefined;
699
+ chatScope?: "all" | "chosen" | undefined;
700
+ chatJids?: string[] | undefined;
676
701
  }[], Error>;
677
702
  /** Public team-member fields every logged-in user may see (`GET /api/users/directory`). */
678
703
  export type { DirectoryUser };
@@ -694,6 +719,7 @@ export declare function useUserDirectory(opts?: {
694
719
  aiAgentId?: number | undefined;
695
720
  aiDeleted?: boolean | undefined;
696
721
  aiNoDirect?: boolean | undefined;
722
+ chatJids?: string[] | undefined;
697
723
  }[], Error>;
698
724
  export declare function useCreateUser(): import("@tanstack/react-query").UseMutationResult<{
699
725
  id: number;
@@ -709,6 +735,8 @@ export declare function useCreateUser(): import("@tanstack/react-query").UseMuta
709
735
  aiAgentId?: number | undefined;
710
736
  aiDeleted?: boolean | undefined;
711
737
  inboxIds?: number[] | undefined;
738
+ chatScope?: "all" | "chosen" | undefined;
739
+ chatJids?: string[] | undefined;
712
740
  }, Error, {
713
741
  username: string;
714
742
  displayName: string;
@@ -729,10 +757,35 @@ export declare function usePatchUser(): import("@tanstack/react-query").UseMutat
729
757
  aiAgentId?: number | undefined;
730
758
  aiDeleted?: boolean | undefined;
731
759
  inboxIds?: number[] | undefined;
760
+ chatScope?: "all" | "chosen" | undefined;
761
+ chatJids?: string[] | undefined;
732
762
  }, Error, {
733
763
  id: number;
734
764
  patch: PatchUserBody;
735
765
  }, unknown>;
766
+ /** Admins: an agent's "Chats this member can see" (`GET /api/users/:id/chats`). */
767
+ export declare function useMemberChats(userId: number, opts?: {
768
+ enabled?: boolean;
769
+ }): import("@tanstack/react-query").UseQueryResult<{
770
+ scope: "all" | "chosen";
771
+ chats: {
772
+ jid: string;
773
+ name: string;
774
+ type: "dm" | "group";
775
+ }[];
776
+ }, Error>;
777
+ /** Admins: replaces it (`PUT /api/users/:id/chats`); the members list and assign dropdowns follow. */
778
+ export declare function useSetMemberChats(): import("@tanstack/react-query").UseMutationResult<{
779
+ scope: "all" | "chosen";
780
+ chats: {
781
+ jid: string;
782
+ name: string;
783
+ type: "dm" | "group";
784
+ }[];
785
+ }, Error, {
786
+ userId: number;
787
+ body: SetMemberChatsBody;
788
+ }, unknown>;
736
789
  export declare function useResetPassword(): import("@tanstack/react-query").UseMutationResult<{
737
790
  password: string;
738
791
  }, Error, number, unknown>;
@@ -0,0 +1,145 @@
1
+ import { type ScheduledTaskPatch } from '@ezychat/shared';
2
+ /**
3
+ * Scheduled tasks of one AI agent (design docs/features/scheduled-tasks/design.md, admins only):
4
+ * the list with the pause reason, the limit and the business time zone, and its changes. Every
5
+ * change reads the list again, so the next run and the last result come from the server.
6
+ */
7
+ export declare const scheduledTasksKey: (agentId: number) => readonly ["scheduled-tasks", number];
8
+ export declare const scheduledRunsKey: (agentId: number, taskId: number) => readonly ["scheduled-tasks", number, "runs", number];
9
+ /** Read again every minute: the next run, the last result and the pause move by themselves. */
10
+ export declare const SCHEDULED_REFETCH_MS = 60000;
11
+ export declare function useScheduledTasks(agentId: number): import("@tanstack/react-query").UseQueryResult<{
12
+ tasks: {
13
+ chat: {
14
+ jid: string;
15
+ name: string;
16
+ type: "dm" | "group";
17
+ } | null;
18
+ nextRunAt: number | null;
19
+ lastRun: {
20
+ id: number;
21
+ at: number;
22
+ trigger: "schedule" | "run_now";
23
+ byUserName: string | null;
24
+ result: "failed" | "sent" | "skipped" | null;
25
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
26
+ messageId: string | null;
27
+ } | null;
28
+ name: string;
29
+ enabled: boolean;
30
+ time: string;
31
+ dayRule: "custom" | "daily" | "weekdays";
32
+ days: number[];
33
+ chatJid: string;
34
+ instruction: string;
35
+ id: number;
36
+ agentId: number;
37
+ }[];
38
+ max: number;
39
+ paused: "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | null;
40
+ timeZone: string;
41
+ inboxId: number | null;
42
+ }, Error>;
43
+ /** Adds a task (409 `scheduled_task_limit`, 400 `chat_not_in_inbox`). */
44
+ export declare function useCreateScheduledTask(agentId: number): import("@tanstack/react-query").UseMutationResult<{
45
+ chat: {
46
+ jid: string;
47
+ name: string;
48
+ type: "dm" | "group";
49
+ } | null;
50
+ nextRunAt: number | null;
51
+ lastRun: {
52
+ id: number;
53
+ at: number;
54
+ trigger: "schedule" | "run_now";
55
+ byUserName: string | null;
56
+ result: "failed" | "sent" | "skipped" | null;
57
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
58
+ messageId: string | null;
59
+ } | null;
60
+ name: string;
61
+ enabled: boolean;
62
+ time: string;
63
+ dayRule: "custom" | "daily" | "weekdays";
64
+ days: number[];
65
+ chatJid: string;
66
+ instruction: string;
67
+ id: number;
68
+ agentId: number;
69
+ }, Error, {
70
+ name: string;
71
+ time: string;
72
+ dayRule: "custom" | "daily" | "weekdays";
73
+ chatJid: string;
74
+ instruction: string;
75
+ enabled?: boolean | undefined;
76
+ days?: number[] | undefined;
77
+ }, unknown>;
78
+ /** Changes a task; the row's on/off switch sends `{ enabled }` only. */
79
+ export declare function useUpdateScheduledTask(agentId: number): import("@tanstack/react-query").UseMutationResult<{
80
+ chat: {
81
+ jid: string;
82
+ name: string;
83
+ type: "dm" | "group";
84
+ } | null;
85
+ nextRunAt: number | null;
86
+ lastRun: {
87
+ id: number;
88
+ at: number;
89
+ trigger: "schedule" | "run_now";
90
+ byUserName: string | null;
91
+ result: "failed" | "sent" | "skipped" | null;
92
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
93
+ messageId: string | null;
94
+ } | null;
95
+ name: string;
96
+ enabled: boolean;
97
+ time: string;
98
+ dayRule: "custom" | "daily" | "weekdays";
99
+ days: number[];
100
+ chatJid: string;
101
+ instruction: string;
102
+ id: number;
103
+ agentId: number;
104
+ }, Error, {
105
+ taskId: number;
106
+ patch: ScheduledTaskPatch;
107
+ }, unknown>;
108
+ export declare function useDeleteScheduledTask(agentId: number): import("@tanstack/react-query").UseMutationResult<unknown, Error, number, unknown>;
109
+ /** The task's last runs, newest first. */
110
+ export declare function useScheduledRuns(agentId: number, taskId: number): import("@tanstack/react-query").UseQueryResult<{
111
+ runs: {
112
+ id: number;
113
+ at: number;
114
+ trigger: "schedule" | "run_now";
115
+ byUserName: string | null;
116
+ result: "failed" | "sent" | "skipped" | null;
117
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
118
+ messageId: string | null;
119
+ }[];
120
+ }, Error>;
121
+ /** Run now (429 `rate_limited`, 409 `scheduled_paused`): answers the run as recorded. */
122
+ export declare function useRunScheduledTask(agentId: number): import("@tanstack/react-query").UseMutationResult<{
123
+ run: {
124
+ id: number;
125
+ at: number;
126
+ trigger: "schedule" | "run_now";
127
+ byUserName: string | null;
128
+ result: "failed" | "sent" | "skipped" | null;
129
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
130
+ messageId: string | null;
131
+ };
132
+ }, Error, number, unknown>;
133
+ /** Preview: one turn, nothing sent or stored. */
134
+ export declare function usePreviewScheduledTask(agentId: number): import("@tanstack/react-query").UseMutationResult<{
135
+ result: "sent" | "skipped";
136
+ text: string | null;
137
+ reason: "window_closed" | "confidential_leak" | "ai_unavailable" | "lookup_failed" | "agent_off" | "ai_disconnected" | "wa_disconnected" | "access_closed" | "nothing_to_say" | "needs_team" | "missed" | "chat_gone" | "send_failed" | "interrupted" | null;
138
+ lookups: {
139
+ title: string;
140
+ sourceLabel: string;
141
+ }[];
142
+ }, Error, {
143
+ chatJid: string;
144
+ instruction: string;
145
+ }, unknown>;
@@ -60,9 +60,13 @@ export declare function useSendTemplate(jid: string): import("@tanstack/react-qu
60
60
  language: string;
61
61
  } | null | undefined;
62
62
  viaAssistant?: boolean | undefined;
63
+ scheduledTask?: {
64
+ id: number;
65
+ name: string | null;
66
+ } | null | undefined;
63
67
  transcript?: string | null | undefined;
64
68
  transcriptLang?: string | null | undefined;
65
- transcriptStatus?: "pending" | "failed" | "ok" | "too_long" | "unsupported" | "skipped" | null | undefined;
69
+ transcriptStatus?: "pending" | "failed" | "ok" | "skipped" | "too_long" | "unsupported" | null | undefined;
66
70
  senderProfile?: {
67
71
  chatJid: string;
68
72
  name: string;
@@ -5,4 +5,4 @@ export declare function AskEzyButton({ request, compact, variant, className, }:
5
5
  compact?: boolean;
6
6
  variant?: 'ghost' | 'outline';
7
7
  className?: string;
8
- }): import("react").JSX.Element;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import type { User } from '@ezychat/shared';
2
+ /**
3
+ * An agent limited to chosen chats (`User.chatScope === 'chosen'`): no Ask Ezy (it reads across
4
+ * chats) and no chat opened or started from a group member. The server refuses both anyway.
5
+ */
6
+ export declare function chosenChatsOnly(user: Pick<User, 'role' | 'chatScope'> | null | undefined): boolean;
7
+ export declare function useChosenChatsOnly(): boolean;