@wix/himalaya-cli 0.1947.0 → 0.1949.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 (188) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/files/src/index.d.ts +23 -2
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/admob-ids.d.ts +4 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +1 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +3 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/social-feed/src/index.d.ts +13 -4
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/video/src/display.d.ts +3 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +8 -2
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/files.mjs +4 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +3 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-video.mjs +4 -0
  11. package/dist/browser-plane/assets.json +5 -5
  12. package/dist/browser-plane/preview-deferred/{da958a2a47eef7082c7892c1cc755a58bbeefcb4b617b47fde87f1ce567b3e64.bin → a8cfd0e17359578587e8937e88dedd40b46d533f08b4d2fdac4c47d5bae6f385.bin} +1 -1
  13. package/dist/browser-plane/sw.js +9 -9
  14. package/dist/cli.mjs +1906 -800
  15. package/dist/preview-assets.generated.bin +0 -0
  16. package/guides/app-icon.md +7 -3
  17. package/guides/getting-started.md +6 -1
  18. package/guides/himi-skill.md +6 -1
  19. package/guides/himi-test.md +30 -1
  20. package/guides/one-app-section-mappings.md +1 -1
  21. package/guides/one-app-to-himi-app.md +23 -16
  22. package/guides/sdk-reference.json +28 -7
  23. package/guides/skill.md +1 -1
  24. package/package.json +2 -2
  25. package/templates/beauty-salon-owner/config.ts +7 -0
  26. package/templates/beauty-salon-owner/dev/index.ts +567 -0
  27. package/templates/beauty-salon-owner/himalaya.content.json +3 -0
  28. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  29. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  30. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  31. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  32. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  33. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  34. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  35. package/templates/branded-lite/l10n/ar.json +21 -0
  36. package/templates/branded-lite/l10n/cs.json +21 -0
  37. package/templates/branded-lite/l10n/da.json +21 -0
  38. package/templates/branded-lite/l10n/de.json +21 -0
  39. package/templates/branded-lite/l10n/el.json +21 -0
  40. package/templates/branded-lite/l10n/en.json +5 -0
  41. package/templates/branded-lite/l10n/es.json +21 -0
  42. package/templates/branded-lite/l10n/fi.json +21 -0
  43. package/templates/branded-lite/l10n/fr.json +21 -0
  44. package/templates/branded-lite/l10n/he.json +21 -0
  45. package/templates/branded-lite/l10n/hu.json +21 -0
  46. package/templates/branded-lite/l10n/id.json +21 -0
  47. package/templates/branded-lite/l10n/it.json +21 -0
  48. package/templates/branded-lite/l10n/ja.json +21 -0
  49. package/templates/branded-lite/l10n/ko.json +21 -0
  50. package/templates/branded-lite/l10n/lt.json +21 -0
  51. package/templates/branded-lite/l10n/nl.json +21 -0
  52. package/templates/branded-lite/l10n/no.json +21 -0
  53. package/templates/branded-lite/l10n/pl.json +21 -0
  54. package/templates/branded-lite/l10n/pt.json +21 -0
  55. package/templates/branded-lite/l10n/ru.json +21 -0
  56. package/templates/branded-lite/l10n/sv.json +21 -0
  57. package/templates/branded-lite/l10n/th.json +21 -0
  58. package/templates/branded-lite/l10n/tr.json +21 -0
  59. package/templates/branded-lite/l10n/uk.json +21 -0
  60. package/templates/branded-lite/l10n/vi.json +21 -0
  61. package/templates/branded-lite/l10n/zh.json +21 -0
  62. package/templates/branded-lite/recipes/form-section.json +958 -0
  63. package/templates/branded-lite/recipes/group-feed.json +221 -3
  64. package/templates/branded-lite/recipes/groups-newsfeed.json +160 -2
  65. package/templates/branded-lite/recipes/video-library.json +475 -0
  66. package/templates/branded-lite/tier5-src/_shared/event-agenda.ts +15 -15
  67. package/templates/branded-lite/tier5-src/_shared/event-schedule-section.ts +8 -8
  68. package/templates/branded-lite/tier5-src/_shared/form-section.ts +640 -0
  69. package/templates/branded-lite/tier5-src/_shared/group-feed-section.ts +119 -7
  70. package/templates/branded-lite/tier5-src/_shared/groups-newsfeed-section.ts +17 -9
  71. package/templates/branded-lite/tier5-src/_shared/videos-section.ts +134 -2
  72. package/templates/branded-lite/tier5-src/himi-branded-lite-form/index.ts +4 -588
  73. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +4 -2
  74. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +7 -6
  75. package/templates/community-club/tier5-src/himi-events-detail/index.ts +7 -6
  76. package/templates/community-club-owner/config.ts +7 -0
  77. package/templates/community-club-owner/dev/index.ts +567 -0
  78. package/templates/community-club-owner/himalaya.content.json +3 -0
  79. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  80. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  81. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  82. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  83. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  84. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  85. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  86. package/templates/conference/tier5-src/_shared/event-agenda.ts +15 -15
  87. package/templates/conference/tier5-src/himi-conference-agenda/index.ts +3 -5
  88. package/templates/conference/tier5-src/himi-conference-home/index.ts +5 -6
  89. package/templates/conference/tier5-src/himi-events-detail/index.ts +7 -6
  90. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +7 -6
  91. package/templates/events-meetups-owner/config.ts +7 -0
  92. package/templates/events-meetups-owner/dev/index.ts +567 -0
  93. package/templates/events-meetups-owner/himalaya.content.json +3 -0
  94. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  95. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  96. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  97. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  98. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  99. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  100. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  101. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +7 -6
  102. package/templates/gym-fitness-owner/config.ts +7 -0
  103. package/templates/gym-fitness-owner/dev/index.ts +567 -0
  104. package/templates/gym-fitness-owner/himalaya.content.json +3 -0
  105. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  106. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  107. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  108. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  109. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  110. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  111. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  112. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +7 -6
  113. package/templates/nonprofit-cause-owner/config.ts +7 -0
  114. package/templates/nonprofit-cause-owner/dev/index.ts +567 -0
  115. package/templates/nonprofit-cause-owner/himalaya.content.json +3 -0
  116. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  117. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  118. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  119. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  120. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  121. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  122. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  123. package/templates/owner-lite/config.ts +7 -0
  124. package/templates/owner-lite/dev/index.ts +567 -0
  125. package/templates/owner-lite/himalaya.content.json +3 -0
  126. package/templates/owner-lite/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  127. package/templates/owner-lite/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  128. package/templates/owner-lite/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  129. package/templates/owner-lite/tier5-src/_shared/owner-maestro-when.ts +13 -0
  130. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  131. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  132. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  133. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-video/index.ts +4 -2
  134. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +7 -6
  135. package/templates/podcast-creator-owner/config.ts +7 -0
  136. package/templates/podcast-creator-owner/dev/index.ts +567 -0
  137. package/templates/podcast-creator-owner/himalaya.content.json +3 -0
  138. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  139. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  140. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  141. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  142. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  143. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  144. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  145. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +7 -6
  146. package/templates/portfolio-creative-owner/config.ts +7 -0
  147. package/templates/portfolio-creative-owner/dev/index.ts +567 -0
  148. package/templates/portfolio-creative-owner/himalaya.content.json +3 -0
  149. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  150. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  151. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  152. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  153. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  154. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  155. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  156. package/templates/professional-services/tier5-src/himi-events-detail/index.ts +7 -6
  157. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +7 -6
  158. package/templates/restaurant-owner/config.ts +7 -0
  159. package/templates/restaurant-owner/dev/index.ts +567 -0
  160. package/templates/restaurant-owner/himalaya.content.json +3 -0
  161. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  162. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  163. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  164. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  165. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  166. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  167. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  168. package/templates/retail-store-owner/config.ts +7 -0
  169. package/templates/retail-store-owner/dev/index.ts +567 -0
  170. package/templates/retail-store-owner/himalaya.content.json +3 -0
  171. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  172. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  173. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  174. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  175. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  176. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  177. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
  178. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +7 -6
  179. package/templates/yoga-studio-owner/config.ts +7 -0
  180. package/templates/yoga-studio-owner/dev/index.ts +567 -0
  181. package/templates/yoga-studio-owner/himalaya.content.json +3 -0
  182. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-activity.ts +151 -0
  183. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-availability.ts +15 -2
  184. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-chat.ts +20 -7
  185. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-when.ts +13 -0
  186. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro/index.ts +60 -11
  187. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-activity/index.ts +228 -0
  188. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +1 -11
@@ -0,0 +1,151 @@
1
+ // What Maestro is doing for a business, as __HIMI_APP_NAME__ reads it from Symphony: the tasks it was
2
+ // given, the routines it runs on a schedule, and the goals it works toward.
3
+ //
4
+ // Shapes measured live on 2026-11-29 and read from the Symphony clients
5
+ // (wix-private/ai-scheduling-assistant). Symphony keeps all three per Space, and a business is
6
+ // the website of a Space, so each read is narrowed to the Spaces of the business on screen.
7
+ // Everything is asked over the owner's own Wix session through the host.
8
+
9
+ import { NATIVE_DATA, type MaestroWixApi } from "./owner-maestro-availability.js";
10
+
11
+ const str = (v: unknown): string => (typeof v === "string" ? v.trim() : "");
12
+ const oneLine = (v: unknown): string => str(v).replace(/\s+/g, " ");
13
+ const newestFirst = <T extends { updated: string }>(rows: T[]): T[] =>
14
+ rows.sort((a, b) => (a.updated < b.updated ? 1 : a.updated > b.updated ? -1 : 0));
15
+
16
+ /** Where a task stands, in the ways the owner cares about. */
17
+ export type TaskStanding = "needs_you" | "working" | "paused" | "done" | "stopped" | "failed";
18
+
19
+ export interface MaestroTask {
20
+ id: string; title: string; standing: TaskStanding; updated: string;
21
+ /** The chat the task was given in: where the owner answers it or reads its result. */
22
+ conversationId: string;
23
+ /** What Maestro asks, when it waits on the owner; else its summary, or what it came to. */
24
+ note: string;
25
+ }
26
+
27
+ interface TaskRow {
28
+ id?: string; title?: string; status?: string; workspaceId?: string; updatedDate?: string; lastActivityAt?: string; finishedAt?: string;
29
+ sourceConversationId?: string; runInFlight?: boolean; finishedResult?: string;
30
+ display?: { summary?: string } | null;
31
+ decisionPrompts?: Array<{ question?: string }> | null;
32
+ }
33
+
34
+ /** Symphony's task status in the owner's terms, as its own clients read it: a task that has ended
35
+ * says how; one that is held on a question for the owner needs them, whatever its status (the
36
+ * hold does not change the status); every other status, one added later included, is being
37
+ * worked on. */
38
+ function standingOf(row: TaskRow): TaskStanding {
39
+ switch (row.status) {
40
+ case "COMPLETED": case "DONE": return "done";
41
+ case "MOOT": case "CANCELLED": case "CANCELED": return "stopped";
42
+ case "FAILED": return "failed";
43
+ default:
44
+ }
45
+ if (row.status === "ACTION_NEEDED" || (row.decisionPrompts ?? []).some((d) => oneLine(d?.question))) return "needs_you";
46
+ return row.status === "PAUSED" ? "paused" : "working";
47
+ }
48
+
49
+ /** The tasks of these Spaces from the last thirty days (Symphony's own window), newest first.
50
+ * Throws when Symphony could not be asked. */
51
+ export async function tasksOf(api: MaestroWixApi, spaceIds: string[]): Promise<MaestroTask[]> {
52
+ if (!spaceIds.length) return [];
53
+ const res = (await api.call("POST", NATIVE_DATA, { action: "tasks", workspaceIds: spaceIds })) as { tasks?: TaskRow[] } | null;
54
+ const rows: MaestroTask[] = [];
55
+ for (const t of res?.tasks ?? []) {
56
+ const id = str(t?.id);
57
+ // Narrowed here as well: what is listed under a business must be that business's.
58
+ if (!id || !spaceIds.includes(str(t.workspaceId)) || rows.some((x) => x.id === id)) continue;
59
+ const standing = standingOf(t);
60
+ const asked = standing === "needs_you" ? oneLine(t.decisionPrompts?.[0]?.question) : "";
61
+ rows.push({
62
+ id, title: oneLine(t.title), standing,
63
+ updated: str(t.lastActivityAt) || str(t.finishedAt) || str(t.updatedDate),
64
+ conversationId: str(t.sourceConversationId),
65
+ // What it came to, when it ended without a summary of its own.
66
+ note: asked || oneLine(t.display?.summary) || oneLine(t.finishedResult),
67
+ });
68
+ }
69
+ return newestFirst(rows);
70
+ }
71
+
72
+ export interface MaestroRoutine {
73
+ id: string; name: string;
74
+ /** When it runs, in Symphony's own words ("Every Monday at 9:00"). */
75
+ schedule: string;
76
+ paused: boolean;
77
+ /** What holds it, when it is not the owner's own pause: Symphony sets these apart from `paused`,
78
+ * and resuming does not lift them. */
79
+ heldBy: "" | "credits" | "error" | "setup";
80
+ /** Over and done: it has an end date that has passed. Not resumable. */
81
+ ended: boolean;
82
+ conversationId: string;
83
+ }
84
+
85
+ interface RoutineRow {
86
+ id?: string; name?: string; workspaceId?: string; paused?: boolean; pausedOutOfCredits?: boolean; pausedDueToUnrecoverableError?: boolean;
87
+ pausedConnectorDisconnected?: boolean; pausedAwaitingSetup?: boolean;
88
+ ended?: boolean; display?: { schedule?: string } | null; targetConversationId?: string;
89
+ }
90
+
91
+ /** How many pages of routines are read at most: a list longer than this is cut, not looped on. */
92
+ const ROUTINE_PAGES = 10;
93
+
94
+ /** The routines of these Spaces. Symphony pages the list, and adds the account's own routines
95
+ * (the morning brief, which belongs to no Space) to every Space's first page: those are left
96
+ * out, since pausing one here would pause it for every business.
97
+ * Throws when Symphony could not be asked. */
98
+ export async function routinesOf(api: MaestroWixApi, spaceIds: string[]): Promise<MaestroRoutine[]> {
99
+ if (!spaceIds.length) return [];
100
+ const rows: MaestroRoutine[] = [];
101
+ let cursor = "";
102
+ for (let page = 0; page < ROUTINE_PAGES; page += 1) {
103
+ const res = (await api.call("POST", NATIVE_DATA, { action: "routines", routineWorkspaceIds: spaceIds, ...(cursor ? { cursor } : {}) })) as { routines?: RoutineRow[]; cursor?: string | null } | null;
104
+ for (const r of res?.routines ?? []) {
105
+ const id = str(r?.id);
106
+ if (!id || !spaceIds.includes(str(r.workspaceId)) || rows.some((x) => x.id === id)) continue;
107
+ rows.push({
108
+ id, name: oneLine(r.name), schedule: oneLine(r.display?.schedule), paused: r.paused === true,
109
+ heldBy: r.pausedOutOfCredits === true ? "credits" : r.pausedDueToUnrecoverableError === true ? "error"
110
+ : r.pausedConnectorDisconnected === true || r.pausedAwaitingSetup === true ? "setup" : "",
111
+ ended: r.ended === true, conversationId: str(r.targetConversationId),
112
+ });
113
+ }
114
+ const next = str(res?.cursor);
115
+ if (!next || next === cursor) break;
116
+ cursor = next;
117
+ }
118
+ return rows;
119
+ }
120
+
121
+ /** Pause or resume a routine. Throws when Symphony did not take it. */
122
+ export async function setRoutinePaused(api: MaestroWixApi, routineId: string, paused: boolean): Promise<void> {
123
+ const res = (await api.call("POST", NATIVE_DATA, { action: "toggle-routine", routineId, paused })) as { ok?: boolean; paused?: boolean } | null;
124
+ // `paused` is echoed back; an answer that says the opposite is a change that was not made.
125
+ if (res?.ok !== true || (typeof res.paused === "boolean" && res.paused !== paused)) throw new Error("routine was not changed");
126
+ }
127
+
128
+ /** Where a goal stands. Abandoned goals are not listed at all. */
129
+ export type GoalStanding = "suggested" | "starting" | "active" | "achieved";
130
+
131
+ export interface MaestroGoal { id: string; title: string; standing: GoalStanding; updated: string; conversationId: string }
132
+
133
+ interface GoalRow { id?: string; title?: string; status?: string; updatedDate?: string; workspaceId?: string; conversationId?: string }
134
+
135
+ const GOAL_STANDING: Record<string, GoalStanding> = { OPPORTUNITY: "suggested", KICKOFF: "starting", ACTIVE: "active", ACHIEVED: "achieved" };
136
+
137
+ /** The goals of these Spaces that are still of interest, newest first. Symphony's goal read takes
138
+ * one Space at most, so the account's goals are read once and narrowed here.
139
+ * Throws when Symphony could not be asked. */
140
+ export async function goalsOf(api: MaestroWixApi, spaceIds: string[]): Promise<MaestroGoal[]> {
141
+ if (!spaceIds.length) return [];
142
+ const res = (await api.call("POST", NATIVE_DATA, { action: "goals", statuses: Object.keys(GOAL_STANDING) })) as { goals?: GoalRow[] } | null;
143
+ const rows: MaestroGoal[] = [];
144
+ for (const g of res?.goals ?? []) {
145
+ const id = str(g?.id);
146
+ const standing = GOAL_STANDING[str(g?.status)];
147
+ if (!id || !standing || !spaceIds.includes(str(g.workspaceId)) || rows.some((x) => x.id === id)) continue;
148
+ rows.push({ id, title: oneLine(g.title), standing, updated: str(g.updatedDate), conversationId: str(g.conversationId) });
149
+ }
150
+ return newestFirst(rows);
151
+ }
@@ -9,7 +9,8 @@ export interface MaestroWixApi {
9
9
  call: (method: string, path: string, body?: unknown, headers?: Record<string, string>) => Promise<unknown>;
10
10
  }
11
11
 
12
- const NATIVE_DATA = "https://manage.wix.com/_serverless/ai-scheduling-assistant-server/native-data";
12
+ /** The Symphony account's own service: one endpoint, many things by its body's `action`. */
13
+ export const NATIVE_DATA = "https://manage.wix.com/_serverless/ai-scheduling-assistant-server/native-data";
13
14
  const SPACES = "https://manage.wix.com/_api/symphony-bff/v1/symphony/workspaces";
14
15
 
15
16
  /** `wix-site-id` makes the host mint the credential for THAT metasite (the Symphony account),
@@ -18,7 +19,7 @@ export const forSymphonyAccount = (metaSiteId: string): Record<string, string> =
18
19
  ({ "wix-site-id": metaSiteId, "Content-Type": "application/json" });
19
20
 
20
21
  interface Recipient { recipient?: { metaSiteId?: string } | null }
21
- interface Spaces { workspaces?: Array<{ name?: string; website?: { metaSiteId?: string; name?: string } | null }> }
22
+ interface Spaces { workspaces?: Array<{ id?: string; name?: string; website?: { metaSiteId?: string; name?: string } | null }> }
22
23
 
23
24
  /** The owner's Symphony metasite, or "" when they have no Symphony account. Throws when the
24
25
  * service could not be asked. */
@@ -44,6 +45,18 @@ export async function isSpaceWebsite(api: MaestroWixApi, account: string, site:
44
45
  return (res?.workspaces ?? []).some((w) => w?.website?.metaSiteId === site);
45
46
  }
46
47
 
48
+ /** The ids of the owner's Spaces whose website is `site`. Symphony keeps tasks, routines and goals
49
+ * per Space, under this id. Throws when it could not be asked. */
50
+ export async function spaceIdsOf(api: MaestroWixApi, account: string, site: string): Promise<string[]> {
51
+ const res = await readSpaces(api, account);
52
+ const ids: string[] = [];
53
+ for (const w of res?.workspaces ?? []) {
54
+ const id = typeof w?.id === "string" ? w.id.trim() : "";
55
+ if (id && site && w?.website?.metaSiteId === site && !ids.includes(id)) ids.push(id);
56
+ }
57
+ return ids;
58
+ }
59
+
47
60
  export interface SpaceWebsite { id: string; name: string; space: string }
48
61
 
49
62
  /** The websites of the owner's Spaces, one per site. Empty when they have no Symphony account.
@@ -5,11 +5,9 @@
5
5
  // Everything is asked over the owner's own Wix session through the host: nothing here holds a
6
6
  // credential. Shared by the Maestro screen and its history screen.
7
7
 
8
- import type { MaestroWixApi } from "./owner-maestro-availability.js";
8
+ import { NATIVE_DATA, type MaestroWixApi } from "./owner-maestro-availability.js";
9
9
  import { uuidV4 } from "./chat-live.js";
10
10
 
11
- const NATIVE_DATA = "https://manage.wix.com/_serverless/ai-scheduling-assistant-server/native-data";
12
-
13
11
  /** Reply text as the Text renderer can show it. The renderer draws inline markdown only (bold,
14
12
  * italic, code), so a heading becomes a bold line, a list marker a bullet, and a link or an
15
13
  * image its label. Safe on a half-streamed reply and on its own output. */
@@ -71,9 +69,13 @@ export async function deleteChat(api: MaestroWixApi, conversationId: string): Pr
71
69
  }
72
70
 
73
71
  export interface PastMessage {
74
- id: string; role: "USER" | "ASSISTANT" | "STOPPED"; text: string; decisionIds: string[]; link: LinkCard | null;
72
+ id: string; role: "USER" | "ASSISTANT" | "STOPPED"; text: string; decisionIds: string[]; link: LinkCard | null; draft: DraftCard | null;
75
73
  }
76
74
 
75
+ /** A draft Maestro prepared for the owner to read and send (an email, measured live 2026-11-29).
76
+ * Shown as what it is and what it is called; it is edited and sent in Symphony. */
77
+ export interface DraftCard { id: string; title: string; subject: string; email: boolean }
78
+
77
79
  export interface LinkCard { name: string; url: string }
78
80
 
79
81
  interface MessageRow {
@@ -97,6 +99,16 @@ export function linkCardOf(bag: Record<string, unknown> | null | undefined): Lin
97
99
  return { name, url };
98
100
  }
99
101
 
102
+ /** The draft a message carries, when it carries one. */
103
+ export function draftCardOf(bag: Record<string, unknown> | null | undefined): DraftCard | null {
104
+ const card = bag?.draftPreviewCard as { draftId?: unknown; title?: unknown; subject?: unknown; kind?: unknown } | undefined;
105
+ const id = typeof card?.draftId === "string" ? card.draftId.trim() : "";
106
+ const title = typeof card?.title === "string" ? card.title.replace(/\s+/g, " ").trim() : "";
107
+ const subject = typeof card?.subject === "string" ? card.subject.replace(/\s+/g, " ").trim() : "";
108
+ if (!id || (!title && !subject)) return null;
109
+ return { id, title, subject, email: card?.kind === "EMAIL" };
110
+ }
111
+
100
112
  /** An https address with a plain host. A worker has no `URL` on every host (JavaScriptCore has
101
113
  * none), so the shape is checked here; the host still decides whether to open it. */
102
114
  export function isHttpsUrl(value: string): boolean {
@@ -118,15 +130,16 @@ export async function chatPage(api: MaestroWixApi, conversationId: string, curso
118
130
  for (const m of rows) {
119
131
  // The marker Symphony writes when a turn was stopped: the owner did that, so the chat says so.
120
132
  if (m.role === "SYSTEM" && m.metadata?.stopMessage === true) {
121
- out.push({ id: m.id as string, role: "STOPPED", text: "", decisionIds: [], link: null });
133
+ out.push({ id: m.id as string, role: "STOPPED", text: "", decisionIds: [], link: null, draft: null });
122
134
  continue;
123
135
  }
124
136
  if (m.role !== "USER" && m.role !== "ASSISTANT") continue;
125
137
  const text = typeof m.content === "string" ? m.content : "";
126
138
  const decisionIds = decisionIdsOf(m.metadata);
127
139
  const link = linkCardOf(m.metadata);
128
- if (!text.trim() && !decisionIds.length && !link) continue;
129
- out.push({ id: m.id as string, role: m.role, text, decisionIds, link });
140
+ const draft = draftCardOf(m.metadata);
141
+ if (!text.trim() && !decisionIds.length && !link && !draft) continue;
142
+ out.push({ id: m.id as string, role: m.role, text, decisionIds, link, draft });
130
143
  }
131
144
  return { messages: out, older: typeof res?.nextCursor === "string" ? res.nextCursor : "" };
132
145
  }
@@ -0,0 +1,13 @@
1
+ // When something in a Maestro list last moved, as its row says it.
2
+
3
+ import { formatClock, formatMonthDayTime } from "./engine-intl.js";
4
+
5
+ /** The time for one from today, whose rows would otherwise all read the same date; the date and
6
+ * the time for an older one. "" for a date that cannot be read. */
7
+ export function whenLabel(updated: string, now: number): string {
8
+ const at = Date.parse(updated);
9
+ if (Number.isNaN(at)) return "";
10
+ const midnight = new Date(now);
11
+ midnight.setHours(0, 0, 0, 0);
12
+ return at >= midnight.getTime() ? formatClock(new Date(at)) : formatMonthDayTime(new Date(at));
13
+ }
@@ -33,8 +33,8 @@ import { currentBusinessId } from "../_shared/owner-selected-site.js";
33
33
  import { forSymphonyAccount, hostCannotRunMaestro, maestroAvailability, type HostCannotRunMaestro } from "../_shared/owner-maestro-availability.js";
34
34
  import { ASK_MAESTRO_NOUNS, askForRecount, clearAskRequest, wasDeleted, isAskMaestroKind, pendingAskRequest, type AskMaestroKind } from "../_shared/owner-maestro-tab.js";
35
35
  import {
36
- chatDecisions, chatIsRunning, chatPage, decisionIdsOf, isHttpsUrl, linkCardOf, mintUpload, pastChats, replyText, sendVerdict, stopTurn, uploadedFile, waitingOnOwner,
37
- type Decision, type LinkCard, type PastMessage, type TurnAttachment, type Verdict, type WaitingAsk,
36
+ chatDecisions, chatIsRunning, chatPage, decisionIdsOf, draftCardOf, isHttpsUrl, linkCardOf, mintUpload, pastChats, replyText, sendVerdict, stopTurn, uploadedFile, waitingOnOwner,
37
+ type Decision, type DraftCard, type LinkCard, type PastMessage, type TurnAttachment, type Verdict, type WaitingAsk,
38
38
  } from "../_shared/owner-maestro-chat.js";
39
39
  import { open as openUrl } from "@himalaya/open-url";
40
40
  import { writeText } from "@himalaya/clipboard";
@@ -116,6 +116,23 @@ function linkBubble(link: LinkCard): Bubble {
116
116
  });
117
117
  }
118
118
 
119
+ const DRAFT_ROW = "draft_";
120
+ /** A draft Maestro prepared. Read-only here: no button, since reading it in full, changing it and
121
+ * sending it happen in Symphony. */
122
+ function draftBubble(draft: DraftCard): Bubble {
123
+ const what = draft.email ? copy.draftEmail() : copy.draft();
124
+ return cardBubble(`${DRAFT_ROW}${draft.id}`, {
125
+ cardTitle: draft.title || what,
126
+ cardText: [draft.title ? what : "", draft.subject ? copy.draftSubject(draft.subject) : ""].filter(Boolean).join(" · "),
127
+ cardStatus: copy.draftWhere(),
128
+ });
129
+ }
130
+
131
+ /** A draft Maestro changed in a later turn is shown under that turn: its earlier card goes, so
132
+ * the one card is where the draft was last touched. */
133
+ const withoutDraft = (messages: Bubble[], draft: DraftCard | null): Bubble[] =>
134
+ (draft ? messages.filter((b) => b.id !== `${DRAFT_ROW}${draft.id}`) : messages);
135
+
119
136
  const decisionRowId = (decisionId: string): string => `decision_${decisionId}`;
120
137
  const isOptionRow = (b: Bubble): boolean => b.optionHidden === "false";
121
138
 
@@ -271,6 +288,10 @@ export interface MaestroState {
271
288
  copyHidden: string;
272
289
  copyNote: string;
273
290
  _copied: string;
291
+ /** Ask again, beside Copy: the owner's last message in this chat as typed, and whether it is
292
+ * offered. Only for a message sent from this screen, so a past chat offers none. */
293
+ _lastAsked: string;
294
+ askAgainHidden: string;
274
295
  /** Dictation: whether the device is listening, and the row that says so (with Done). What is
275
296
  * heard lands in the composer for the owner to read and send; it is never sent for them. */
276
297
  listening: boolean;
@@ -296,6 +317,10 @@ const copy = {
296
317
  historyFailed: () => copyParam("ownerMaestro.historyFailed", "That conversation couldn't be opened. Try again in a moment."),
297
318
  connectTitle: (name: string) => copyParam("ownerMaestro.connect.title", "Connect {name}").replace("{name}", name),
298
319
  connectText: () => copyParam("ownerMaestro.connect.text", "Maestro needs this connection to continue."),
320
+ draft: () => copyParam("ownerMaestro.draft", "Draft"),
321
+ draftEmail: () => copyParam("ownerMaestro.draftEmail", "Email draft"),
322
+ draftSubject: (subject: string) => copyParam("ownerMaestro.draftSubject", "Subject: {subject}").replace("{subject}", subject),
323
+ draftWhere: () => copyParam("ownerMaestro.draftWhere", "Read, edit and send it in Symphony."),
299
324
  connect: () => copyParam("ownerMaestro.connect.action", "Connect"),
300
325
  decisionTitle: () => copyParam("ownerMaestro.decision.title", "Maestro is waiting on your decision"),
301
326
  decisionUnread: () => copyParam("ownerMaestro.decision.unread", "This decision couldn't be loaded here. Answer it in Symphony."),
@@ -405,7 +430,7 @@ const initial: MaestroState = {
405
430
  messages: [], emptyHidden: "false", prompts: [], quickReplies: [], quickRepliesHidden: "true",
406
431
  input: "", hasInput: false, noInput: true, busy: false, idle: true, statusText: "", contextLabel: "", contextHidden: "true", error: "", scrollSend: "", scrollAnchor: "", ok: false,
407
432
  _site: "", _account: "", _convId: "", _role: "", _openId: "", _openRaw: "", _turn: 0, _context: "", _decisionIds: [], _resumedId: "", _askKey: "", _started: false, _stopPending: "",
408
- _older: "", olderHidden: "true", copyHidden: "true", copyNote: "", _copied: "", _watching: "", _watchLeft: 0,
433
+ _older: "", olderHidden: "true", copyHidden: "true", copyNote: "", _copied: "", _lastAsked: "", askAgainHidden: "true", _watching: "", _watchLeft: 0,
409
434
  waiting: [], waitingHidden: "true", attachments: [], attachmentsHidden: "true", listening: false, listeningHidden: "true",
410
435
  };
411
436
 
@@ -578,7 +603,7 @@ const freshChat = (s: MaestroState, input = ""): MaestroState => ({
578
603
  input, hasInput: input.trim().length > 0, noInput: input.trim().length === 0,
579
604
  busy: false, idle: true, statusText: "", contextLabel: "", contextHidden: "true", error: "", scrollSend: "", scrollAnchor: "",
580
605
  _convId: "", _role: "", _openId: "", _openRaw: "", _context: "", _decisionIds: [], _resumedId: "", _askKey: "",
581
- _older: "", _copied: "", _watching: "", _watchLeft: 0,
606
+ _older: "", _copied: "", _lastAsked: "", _watching: "", _watchLeft: 0,
582
607
  });
583
608
 
584
609
  /** `s` with the draft the owner typed while an action was waiting on Symphony. */
@@ -613,7 +638,10 @@ async function send(s: MaestroState, raw: string, choice?: { askId: string; opti
613
638
  dropAskRequest(s._askKey);
614
639
  const turn = s._turn + 1;
615
640
  const next: MaestroState = {
616
- ...s, _convId: convId, _turn: turn, _role: "", _openId: "", _openRaw: "", _decisionIds: [], _started: false, _stopPending: "",
641
+ ...s, _convId: convId, _turn: turn,
642
+ // Not an option the owner tapped, nor a message that went with files: asked again as words
643
+ // alone, neither would be the same message.
644
+ _lastAsked: choice || files.length ? "" : text, _role: "", _openId: "", _openRaw: "", _decisionIds: [], _started: false, _stopPending: "",
617
645
  // The owner's message says what went with it: the files are not drawn in the transcript.
618
646
  messages: [...settled(s.messages), userBubble(`u${turn}`, [text, ...files.map((f) => copy.attached(f.fileName))].join("\n")), thinkingBubble()],
619
647
  emptyHidden: "true", quickReplies: [], quickRepliesHidden: "true",
@@ -675,11 +703,13 @@ function withStep(s: MaestroState, line: string): MaestroState {
675
703
  /** The cards one event names: a link is drawn at once, a decision is noted for the turn's end. */
676
704
  function withEventCards(s: MaestroState, data: Record<string, unknown>): MaestroState {
677
705
  const link = linkCardOf(data);
706
+ const draft = draftCardOf(data);
678
707
  const ids = decisionIdsOf(data).filter((id) => !s._decisionIds.includes(id));
679
- if (!link && !ids.length) return s;
708
+ if (!link && !draft && !ids.length) return s;
709
+ const cards = [...(link ? [linkBubble(link)] : []), ...(draft ? [draftBubble(draft)] : [])];
680
710
  return {
681
711
  ...s,
682
- messages: link ? withCards(s.messages, [linkBubble(link)]) : s.messages,
712
+ messages: cards.length ? withCards(withoutDraft(s.messages, draft), cards) : s.messages,
683
713
  _decisionIds: [...s._decisionIds, ...ids],
684
714
  };
685
715
  }
@@ -692,6 +722,7 @@ async function pageRows(api: WixApi, conversationId: string, past: PastMessage[]
692
722
  if (m.role === "STOPPED") { messages.push(noteBubble(`h_${m.id}`, copy.stopped())); continue; }
693
723
  if (m.text.trim()) messages.push(m.role === "USER" ? userBubble(`h_${m.id}`, m.text) : assistantBubble(`h_${m.id}`, replyText(m.text)));
694
724
  if (m.link) messages = withCards(messages, [linkBubble(m.link)]);
725
+ if (m.draft) messages = withCards(withoutDraft(messages, m.draft), [draftBubble(m.draft)]);
695
726
  for (const id of m.decisionIds) if (!decisionIds.includes(id)) decisionIds.push(id);
696
727
  }
697
728
  return withCards(messages, await decisionCards(api, conversationId, decisionIds));
@@ -727,13 +758,23 @@ async function upload(chipId: string, handle: FileHandle): Promise<void> {
727
758
  await (svc as unknown as { uploaded?: (r: { id: string; file: TurnAttachment | null }) => Promise<unknown> }).uploaded?.({ id: chipId, file: done });
728
759
  }
729
760
 
761
+ /** The last row that says something. A draft card after a reply is part of that reply, and it
762
+ * never goes away: Copy and Ask again look past it. */
763
+ function lastSaid(messages: Bubble[]): Bubble | undefined {
764
+ let at = messages.length - 1;
765
+ while (at > 0 && messages[at].id.startsWith(DRAFT_ROW)) at -= 1;
766
+ return messages[at];
767
+ }
768
+
730
769
  /** What every action's result is finished with: the flags that follow from the rest of the
731
770
  * state, so no action has to remember them. */
732
771
  function derived<T extends MaestroState>(s: T): T {
733
- const last = s.messages[s.messages.length - 1];
772
+ const last = lastSaid(s.messages);
734
773
  const copyable = !s.busy && s.phase === "ready" && !!last && last.assistantHidden === "false" && !!last.content;
735
774
  const olderHidden = s._older && !s.busy ? "false" : "true";
736
775
  const copyHidden = copyable ? "false" : "true";
776
+ // Not while files are picked for the next message: asking again would take them with it.
777
+ const askAgainHidden = copyable && s._lastAsked && chips.length === 0 ? "false" : "true";
737
778
  // "Copied" is about one reply: it goes when that reply is no longer the last thing said.
738
779
  const copyNote = copyable && s._copied === last.id ? copy.copied() : "";
739
780
  // Only on an empty chat, where the greeting and the prompts are.
@@ -741,9 +782,9 @@ function derived<T extends MaestroState>(s: T): T {
741
782
  // The same object when nothing follows differently: an action that changed nothing still says so.
742
783
  const attachmentsHidden = chips.length > 0 ? "false" : "true";
743
784
  const listeningHidden = listeningNow ? "false" : "true";
744
- if (s.olderHidden === olderHidden && s.copyHidden === copyHidden && s.copyNote === copyNote && s.waitingHidden === waitingHidden
785
+ if (s.olderHidden === olderHidden && s.copyHidden === copyHidden && s.askAgainHidden === askAgainHidden && s.copyNote === copyNote && s.waitingHidden === waitingHidden
745
786
  && s.attachmentsHidden === attachmentsHidden && s.listeningHidden === listeningHidden && s.listening === listeningNow && s.attachments === chips && s.waiting === waitingAsks) return s;
746
- return { ...s, attachments: chips, waiting: waitingAsks, listening: listeningNow, olderHidden, copyHidden, copyNote, waitingHidden, attachmentsHidden, listeningHidden };
787
+ return { ...s, attachments: chips, waiting: waitingAsks, listening: listeningNow, olderHidden, copyHidden, askAgainHidden, copyNote, waitingHidden, attachmentsHidden, listeningHidden };
747
788
  }
748
789
 
749
790
  /** The state as it is now, for a result that must not undo what happened while an action waited. */
@@ -832,6 +873,7 @@ const textOf = (arg: Arg): string => {
832
873
 
833
874
  type MaestroActions = {
834
875
  load: (s: MaestroState, arg?: unknown) => Promise<MaestroState>;
876
+ askAgain: (s: MaestroState) => Promise<MaestroState>;
835
877
  setInput: (s: MaestroState, arg?: Arg) => Promise<MaestroState>;
836
878
  submit: (s: MaestroState, arg?: Arg) => Promise<MaestroState>;
837
879
  usePrompt: (s: MaestroState, arg?: Arg) => Promise<MaestroState>;
@@ -971,6 +1013,13 @@ const svc = defineService<MaestroState, MaestroActions>(SERVICE, {
971
1013
  return { ...s, input, hasInput: has, noInput: !has };
972
1014
  },
973
1015
  submit: async (s, arg) => send(s, textOf(arg) || s.input),
1016
+ // The owner's last message, sent again as a new turn: Symphony has no way to redo a reply in place.
1017
+ askAgain: async (s) => {
1018
+ if (!s._lastAsked || chips.length) return s;
1019
+ const sent = await send(s, s._lastAsked);
1020
+ // What the owner has typed since is not what was sent: it stays in the composer.
1021
+ return sent === s || !s.input ? sent : { ...sent, input: s.input, hasInput: s.hasInput, noInput: s.noInput };
1022
+ },
974
1023
  usePrompt: async (s, arg) => {
975
1024
  const id = typeof arg === "object" ? arg?.id : "";
976
1025
  const prompt = s.prompts.find((p) => p.id === id);
@@ -1032,7 +1081,7 @@ const svc = defineService<MaestroState, MaestroActions>(SERVICE, {
1032
1081
  cardSecondary: async (s, arg) => decide(s, typeof arg === "object" ? arg?.id ?? "" : "", "REFUSED"),
1033
1082
  // Copy the last reply, as Maestro wrote it for the screen.
1034
1083
  copyReply: async (s) => {
1035
- const last = s.messages[s.messages.length - 1];
1084
+ const last = lastSaid(s.messages);
1036
1085
  if (s.busy || !last || last.assistantHidden !== "false" || !last.content) return s;
1037
1086
  // Emphasis marks are for the renderer: what is copied is the words.
1038
1087
  try { await writeText(last.content.replace(/\*\*/g, "")); } catch { return s; }