@celljs/ta-web 4.12.0 → 4.13.1

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 (229) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-extension.js +14 -0
  4. package/esm/browser/assistant/assistant-initiative.d.ts +27 -0
  5. package/esm/browser/assistant/assistant-initiative.js +76 -0
  6. package/esm/browser/assistant/assistant-task-source.d.ts +7 -0
  7. package/esm/browser/assistant/assistant-task-source.js +12 -2
  8. package/esm/browser/assistant/assistant-view.js +5 -4
  9. package/esm/browser/assistant/assistant.d.ts +5 -0
  10. package/esm/browser/assistant/assistant.js +25 -6
  11. package/esm/browser/components/app-nav.d.ts +3 -1
  12. package/esm/browser/components/app-nav.js +5 -2
  13. package/esm/browser/components/app-view.js +18 -9
  14. package/esm/browser/components/asks-badge.d.ts +5 -0
  15. package/esm/browser/components/asks-badge.js +8 -0
  16. package/esm/browser/components/chat-asks.d.ts +46 -0
  17. package/esm/browser/components/chat-asks.js +101 -0
  18. package/esm/browser/components/chat-list.d.ts +7 -1
  19. package/esm/browser/components/chat-list.js +46 -17
  20. package/esm/browser/components/composer-addon-util.d.ts +11 -0
  21. package/esm/browser/components/composer-addon-util.js +40 -0
  22. package/esm/browser/components/composer-addons.d.ts +1 -7
  23. package/esm/browser/components/composer-addons.js +1 -27
  24. package/esm/browser/components/composer.d.ts +7 -1
  25. package/esm/browser/components/composer.js +33 -20
  26. package/esm/browser/components/connection-bar.js +31 -12
  27. package/esm/browser/components/conversation-scroll-util.d.ts +5 -0
  28. package/esm/browser/components/conversation-scroll-util.js +18 -0
  29. package/esm/browser/components/conversation-scroll.d.ts +12 -2
  30. package/esm/browser/components/conversation-scroll.js +68 -5
  31. package/esm/browser/components/discover-view.js +5 -1
  32. package/esm/browser/components/earlier-messages.d.ts +10 -3
  33. package/esm/browser/components/earlier-messages.js +14 -8
  34. package/esm/browser/components/folder-picker.d.ts +2 -0
  35. package/esm/browser/components/folder-picker.js +7 -0
  36. package/esm/browser/components/host-view.d.ts +1 -1
  37. package/esm/browser/components/markdown.js +4 -2
  38. package/esm/browser/components/media.js +4 -39
  39. package/esm/browser/components/mermaid-view.js +45 -3
  40. package/esm/browser/components/message-footer.d.ts +2 -0
  41. package/esm/browser/components/message-footer.js +8 -1
  42. package/esm/browser/components/message-list.d.ts +12 -0
  43. package/esm/browser/components/message-list.js +156 -25
  44. package/esm/browser/components/phone-shell.d.ts +7 -2
  45. package/esm/browser/components/phone-shell.js +7 -3
  46. package/esm/browser/components/relay-services.d.ts +24 -0
  47. package/esm/browser/components/relay-services.js +249 -0
  48. package/esm/browser/components/relay-view.js +17 -1
  49. package/esm/browser/components/remote-hosts.js +1 -1
  50. package/esm/browser/components/session-view.js +16 -4
  51. package/esm/browser/components/settings-controls.js +3 -3
  52. package/esm/browser/components/settings-parts.js +13 -1
  53. package/esm/browser/components/ta-avatar.js +6 -0
  54. package/esm/browser/components/tool-result.d.ts +13 -0
  55. package/esm/browser/components/tool-result.js +138 -0
  56. package/esm/browser/components/tool-view.js +5 -15
  57. package/esm/browser/components/web-composer.js +2 -1
  58. package/esm/browser/extension/extension-view.d.ts +3 -1
  59. package/esm/browser/extension/extension-view.js +7 -0
  60. package/esm/browser/extension/icons.js +9 -1
  61. package/esm/browser/extension/web-api-components.d.ts +3 -3
  62. package/esm/browser/extension/web-api-contributions.d.ts +119 -0
  63. package/esm/browser/extension/web-extension-api.d.ts +23 -46
  64. package/esm/browser/extension/web-extension-context.d.ts +6 -1
  65. package/esm/browser/extension/web-extension-context.js +63 -6
  66. package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
  67. package/esm/browser/extension/web-extension-protocol.js +1 -0
  68. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  69. package/esm/browser/extension/web-extension-run.js +3 -0
  70. package/esm/browser/extension/web-extensions.d.ts +2 -8
  71. package/esm/browser/extension/web-extensions.js +9 -35
  72. package/esm/browser/extension/web-page-list.d.ts +25 -0
  73. package/esm/browser/extension/web-page-list.js +35 -0
  74. package/esm/browser/extension/web-session-notices.d.ts +6 -1
  75. package/esm/browser/extension/web-session-notices.js +30 -4
  76. package/esm/browser/extension/web-sharing.d.ts +5 -2
  77. package/esm/browser/extension/web-sharing.js +10 -1
  78. package/esm/browser/i18n/locales.d.ts +69 -3
  79. package/esm/browser/i18n/messages.d.ts +68 -2
  80. package/esm/browser/i18n/messages.js +138 -6
  81. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  82. package/esm/browser/markdown/code-renderers.js +4 -0
  83. package/esm/browser/markdown/lazy.d.ts +8 -0
  84. package/esm/browser/markdown/lazy.js +35 -0
  85. package/esm/browser/markdown/mermaid.d.ts +15 -3
  86. package/esm/browser/markdown/mermaid.js +45 -6
  87. package/esm/browser/notices/notices-protocol.d.ts +5 -0
  88. package/esm/browser/notices/notices.d.ts +19 -0
  89. package/esm/browser/notices/notices.js +85 -2
  90. package/esm/browser/notices/session-notices.d.ts +5 -2
  91. package/esm/browser/notices/session-notices.js +10 -1
  92. package/esm/browser/style/base.d.ts +1 -1
  93. package/esm/browser/style/base.js +2 -1
  94. package/esm/browser/style/conversation.d.ts +1 -1
  95. package/esm/browser/style/conversation.js +51 -0
  96. package/esm/browser/style/device.js +3 -0
  97. package/esm/browser/style/layout.d.ts +1 -1
  98. package/esm/browser/style/layout.js +24 -9
  99. package/esm/browser/style/pages.d.ts +1 -1
  100. package/esm/browser/style/pages.js +2 -0
  101. package/esm/browser/style/phone.d.ts +1 -1
  102. package/esm/browser/style/phone.js +2 -0
  103. package/esm/browser/style/shell.d.ts +1 -1
  104. package/esm/browser/style/shell.js +14 -3
  105. package/esm/browser/util/desktop.d.ts +18 -1
  106. package/esm/browser/util/desktop.js +13 -0
  107. package/esm/browser/util/process.d.ts +26 -1
  108. package/esm/browser/util/process.js +79 -5
  109. package/esm/browser/util/progress.d.ts +6 -1
  110. package/esm/browser/util/progress.js +11 -2
  111. package/esm/browser/util/scroll-rest.d.ts +10 -0
  112. package/esm/browser/util/scroll-rest.js +44 -0
  113. package/esm/browser/util/tool-result.d.ts +32 -0
  114. package/esm/browser/util/tool-result.js +85 -0
  115. package/esm/browser/util/tool.js +7 -0
  116. package/lib/browser/assistant/assistant-extension.js +14 -0
  117. package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
  118. package/lib/browser/assistant/assistant-initiative.js +80 -0
  119. package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
  120. package/lib/browser/assistant/assistant-task-source.js +12 -2
  121. package/lib/browser/assistant/assistant-view.js +3 -2
  122. package/lib/browser/assistant/assistant.d.ts +5 -0
  123. package/lib/browser/assistant/assistant.js +24 -5
  124. package/lib/browser/components/app-nav.d.ts +3 -1
  125. package/lib/browser/components/app-nav.js +5 -2
  126. package/lib/browser/components/app-view.js +17 -8
  127. package/lib/browser/components/asks-badge.d.ts +6 -0
  128. package/lib/browser/components/asks-badge.js +44 -0
  129. package/lib/browser/components/chat-asks.d.ts +47 -0
  130. package/lib/browser/components/chat-asks.js +104 -0
  131. package/lib/browser/components/chat-list.d.ts +7 -1
  132. package/lib/browser/components/chat-list.js +46 -17
  133. package/lib/browser/components/composer-addon-util.d.ts +12 -0
  134. package/lib/browser/components/composer-addon-util.js +76 -0
  135. package/lib/browser/components/composer-addons.d.ts +1 -7
  136. package/lib/browser/components/composer-addons.js +2 -29
  137. package/lib/browser/components/composer.d.ts +7 -1
  138. package/lib/browser/components/composer.js +33 -19
  139. package/lib/browser/components/connection-bar.js +30 -11
  140. package/lib/browser/components/conversation-scroll-util.d.ts +5 -0
  141. package/lib/browser/components/conversation-scroll-util.js +18 -0
  142. package/lib/browser/components/conversation-scroll.d.ts +12 -2
  143. package/lib/browser/components/conversation-scroll.js +68 -5
  144. package/lib/browser/components/discover-view.js +5 -1
  145. package/lib/browser/components/earlier-messages.d.ts +10 -3
  146. package/lib/browser/components/earlier-messages.js +16 -9
  147. package/lib/browser/components/folder-picker.d.ts +2 -0
  148. package/lib/browser/components/folder-picker.js +7 -0
  149. package/lib/browser/components/host-view.d.ts +1 -1
  150. package/lib/browser/components/markdown.js +3 -1
  151. package/lib/browser/components/media.js +3 -38
  152. package/lib/browser/components/mermaid-view.js +45 -3
  153. package/lib/browser/components/message-footer.d.ts +2 -0
  154. package/lib/browser/components/message-footer.js +8 -0
  155. package/lib/browser/components/message-list.d.ts +12 -0
  156. package/lib/browser/components/message-list.js +153 -20
  157. package/lib/browser/components/phone-shell.d.ts +7 -2
  158. package/lib/browser/components/phone-shell.js +7 -3
  159. package/lib/browser/components/relay-services.d.ts +25 -0
  160. package/lib/browser/components/relay-services.js +286 -0
  161. package/lib/browser/components/relay-view.js +17 -1
  162. package/lib/browser/components/remote-hosts.js +1 -1
  163. package/lib/browser/components/session-view.js +15 -3
  164. package/lib/browser/components/settings-controls.js +3 -3
  165. package/lib/browser/components/settings-parts.js +13 -1
  166. package/lib/browser/components/ta-avatar.js +6 -0
  167. package/lib/browser/components/tool-result.d.ts +14 -0
  168. package/lib/browser/components/tool-result.js +175 -0
  169. package/lib/browser/components/tool-view.js +10 -20
  170. package/lib/browser/components/web-composer.js +2 -1
  171. package/lib/browser/extension/extension-view.d.ts +3 -1
  172. package/lib/browser/extension/extension-view.js +8 -1
  173. package/lib/browser/extension/icons.js +8 -0
  174. package/lib/browser/extension/web-api-components.d.ts +3 -3
  175. package/lib/browser/extension/web-api-contributions.d.ts +119 -0
  176. package/lib/browser/extension/web-extension-api.d.ts +23 -46
  177. package/lib/browser/extension/web-extension-context.d.ts +6 -1
  178. package/lib/browser/extension/web-extension-context.js +63 -6
  179. package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
  180. package/lib/browser/extension/web-extension-protocol.js +1 -0
  181. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  182. package/lib/browser/extension/web-extension-run.js +3 -0
  183. package/lib/browser/extension/web-extensions.d.ts +2 -8
  184. package/lib/browser/extension/web-extensions.js +9 -35
  185. package/lib/browser/extension/web-page-list.d.ts +26 -0
  186. package/lib/browser/extension/web-page-list.js +39 -0
  187. package/lib/browser/extension/web-session-notices.d.ts +6 -1
  188. package/lib/browser/extension/web-session-notices.js +30 -4
  189. package/lib/browser/extension/web-sharing.d.ts +5 -2
  190. package/lib/browser/extension/web-sharing.js +10 -1
  191. package/lib/browser/i18n/locales.d.ts +69 -3
  192. package/lib/browser/i18n/messages.d.ts +68 -2
  193. package/lib/browser/i18n/messages.js +138 -6
  194. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  195. package/lib/browser/markdown/code-renderers.js +5 -1
  196. package/lib/browser/markdown/lazy.d.ts +8 -0
  197. package/lib/browser/markdown/lazy.js +37 -1
  198. package/lib/browser/markdown/mermaid.d.ts +15 -3
  199. package/lib/browser/markdown/mermaid.js +44 -5
  200. package/lib/browser/notices/notices-protocol.d.ts +5 -0
  201. package/lib/browser/notices/notices.d.ts +19 -0
  202. package/lib/browser/notices/notices.js +84 -1
  203. package/lib/browser/notices/session-notices.d.ts +5 -2
  204. package/lib/browser/notices/session-notices.js +10 -1
  205. package/lib/browser/style/base.d.ts +1 -1
  206. package/lib/browser/style/base.js +2 -1
  207. package/lib/browser/style/conversation.d.ts +1 -1
  208. package/lib/browser/style/conversation.js +51 -0
  209. package/lib/browser/style/device.js +3 -0
  210. package/lib/browser/style/layout.d.ts +1 -1
  211. package/lib/browser/style/layout.js +24 -9
  212. package/lib/browser/style/pages.d.ts +1 -1
  213. package/lib/browser/style/pages.js +2 -0
  214. package/lib/browser/style/phone.d.ts +1 -1
  215. package/lib/browser/style/phone.js +2 -0
  216. package/lib/browser/style/shell.d.ts +1 -1
  217. package/lib/browser/style/shell.js +14 -3
  218. package/lib/browser/util/desktop.d.ts +18 -1
  219. package/lib/browser/util/desktop.js +13 -0
  220. package/lib/browser/util/process.d.ts +26 -1
  221. package/lib/browser/util/process.js +79 -5
  222. package/lib/browser/util/progress.d.ts +6 -1
  223. package/lib/browser/util/progress.js +11 -2
  224. package/lib/browser/util/scroll-rest.d.ts +11 -0
  225. package/lib/browser/util/scroll-rest.js +47 -0
  226. package/lib/browser/util/tool-result.d.ts +33 -0
  227. package/lib/browser/util/tool-result.js +88 -0
  228. package/lib/browser/util/tool.js +7 -0
  229. package/package.json +7 -7
@@ -15,7 +15,9 @@ export declare const ChatIcons: React.Context<{
15
15
  /** The avatars that web extensions registered for the sessions of their groups. */
16
16
  export declare const SessionAvatars: React.Context<Record<string, React.ComponentType<import("./web-extension-api.js").WebAvatarProps>>>;
17
17
  /** What web extensions add to the menu of a conversation of a list (WebExtensionAPI.registerSessionMenu). */
18
- export declare const SessionMenus: React.Context<import("./web-extension-api.js").WebSessionMenu[]>;
18
+ export declare const SessionMenus: React.Context<import("./web-api-contributions.js").WebSessionMenu[]>;
19
+ /** The web extensions loaded: what a message one of their packages sent as the user calls it (TaMessageSource). */
20
+ export declare const LoadedExtensions: React.Context<import("./web-extension-protocol.js").LoadedWebExtension[]>;
19
21
  interface BoundaryProps {
20
22
  name: string;
21
23
  /** A new value (a new component) tries again after a failure. */
@@ -1,6 +1,8 @@
1
+ import { TA_RESUME_MESSAGE } from '@celljs/ta-protocol';
1
2
  import * as React from 'react';
2
3
  import { Callout } from '../components/callout.js';
3
4
  import { Markdown } from '../components/markdown.js';
5
+ import { ResumeBreak } from '../components/message-footer.js';
4
6
  import { useT } from '../i18n/use-t.js';
5
7
  import { MessageUtil } from '../util/message.js';
6
8
  /** The renderers of custom messages that web extensions registered. */
@@ -13,6 +15,8 @@ export const ChatIcons = React.createContext({ entries: [], version: 0 });
13
15
  export const SessionAvatars = React.createContext({});
14
16
  /** What web extensions add to the menu of a conversation of a list (WebExtensionAPI.registerSessionMenu). */
15
17
  export const SessionMenus = React.createContext([]);
18
+ /** The web extensions loaded: what a message one of their packages sent as the user calls it (TaMessageSource). */
19
+ export const LoadedExtensions = React.createContext([]);
16
20
  /** What a web extension draws: when it throws, it says so in its place and the page goes on. */
17
21
  export class ExtensionBoundary extends React.Component {
18
22
  constructor() {
@@ -45,6 +49,9 @@ function ExtensionError({ name, error }) {
45
49
  /** A custom message of pi: with the renderer of its type, or as text when it is to be shown. */
46
50
  export function CustomMessage({ message }) {
47
51
  const Renderer = React.useContext(MessageRenderers)[message.customType];
52
+ if (message.customType === TA_RESUME_MESSAGE) {
53
+ return React.createElement(ResumeBreak, null);
54
+ }
48
55
  if (Renderer) {
49
56
  return (React.createElement(ExtensionBoundary, { name: message.customType, resetKey: Renderer },
50
57
  React.createElement(Renderer, { message: message })));
@@ -1,7 +1,8 @@
1
- import { AlarmClock, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, House, Image, Info, KeyRound, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
1
+ import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
2
2
  /** The icons a web extension gets as `pi.ui.icons`; names are lucide's. Only add: removing one breaks extensions. */
3
3
  export const WEB_ICONS = Object.freeze({
4
4
  AlarmClock,
5
+ Aperture,
5
6
  ArrowDown,
6
7
  ArrowLeft,
7
8
  ArrowRight,
@@ -20,6 +21,7 @@ export const WEB_ICONS = Object.freeze({
20
21
  ChevronsUpDown,
21
22
  CircleAlert,
22
23
  CircleHelp,
24
+ Cloud,
23
25
  Clipboard,
24
26
  Clock,
25
27
  Code,
@@ -30,6 +32,7 @@ export const WEB_ICONS = Object.freeze({
30
32
  CornerDownRight,
31
33
  CornerUpLeft,
32
34
  Crown,
35
+ Database,
33
36
  Download,
34
37
  Ellipsis,
35
38
  ExternalLink,
@@ -54,10 +57,13 @@ export const WEB_ICONS = Object.freeze({
54
57
  Globe,
55
58
  Grip,
56
59
  Hash,
60
+ Heart,
57
61
  House,
58
62
  Image,
63
+ ImagePlus,
59
64
  Info,
60
65
  KeyRound,
66
+ Laptop,
61
67
  LayoutDashboard,
62
68
  Link,
63
69
  List,
@@ -75,6 +81,7 @@ export const WEB_ICONS = Object.freeze({
75
81
  MessagesSquare,
76
82
  Mic,
77
83
  Minus,
84
+ MonitorSmartphone,
78
85
  MousePointerClick,
79
86
  PackageOpen,
80
87
  Paperclip,
@@ -86,6 +93,7 @@ export const WEB_ICONS = Object.freeze({
86
93
  Power,
87
94
  Puzzle,
88
95
  QrCode,
96
+ Radar,
89
97
  RefreshCw,
90
98
  Regex,
91
99
  Replace,
@@ -1,6 +1,6 @@
1
1
  /** Part of the web extension API (web-extension-api.ts, which exports it all): the props of the components of `ui`. */
2
2
  import type * as React from 'react';
3
- import type { TextSelection } from './web-extension-api.js';
3
+ import type { TextSelection, WebIcon } from './web-extension-api.js';
4
4
  export interface WebModelPickerProps {
5
5
  /** The directory whose settings give the models and the default; default: that of ta serve. */
6
6
  cwd?: string;
@@ -266,8 +266,8 @@ export interface WebComposerProps {
266
266
  export interface WebComposerAction {
267
267
  key: string;
268
268
  label: string;
269
- /** On the left: an icon of 16 pixels, or an avatar. */
270
- icon?: React.ReactNode;
269
+ /** On the left: an icon of 16 pixels, or an avatar; an icon of `ui.icons` as it is is drawn at 16 pixels. */
270
+ icon?: React.ReactNode | WebIcon;
271
271
  /** After the label of a setting, quieter: its value now; on a tile, shown on hover. */
272
272
  detail?: string;
273
273
  disabled?: boolean;
@@ -25,7 +25,10 @@ export interface WebSettingsSection {
25
25
  /** A row of the settings of an extension: a label and a description as Ta's rows have, and its control. */
26
26
  export interface WebSettingRow {
27
27
  key: string;
28
+ /** Empty for a row that is all control (a panel that says what it is itself); still found by `search`. */
28
29
  label: WebLabel;
30
+ /** More words the search of the settings finds it by. */
31
+ search?: WebLabel;
29
32
  description?: WebLabel;
30
33
  /** The control, beside the label; with `stacked`, under it, for a wide one (a model picker, a list). */
31
34
  render: React.ComponentType;
@@ -101,6 +104,11 @@ export interface WebView {
101
104
  discover?: boolean;
102
105
  /** A page: the line a list shows under its name, as a messenger does — the last thing said there, and when. */
103
106
  preview?(): WebViewPreview | undefined;
107
+ /**
108
+ * A page under Discover: a small mark at the end of its row, as WeChat shows the face of the friend who posted last
109
+ * by Moments. Nothing to count; nothing, when there is nothing new.
110
+ */
111
+ mark?: React.ComponentType;
104
112
  /** A page: whoever is there answers now; a list that shows it marks it so, as a conversation answering. */
105
113
  busy?(): boolean;
106
114
  /** What `preview` or `busy` gives changed: the lists read it again. */
@@ -130,6 +138,36 @@ export interface WebShareTarget {
130
138
  /** Of a package of this computer (listPackages, or one of its web extensions), handed on through the relay. */
131
139
  packageId?: string;
132
140
  }
141
+ /** How far something goes on its own: `act` does it, the rest asks the user first (WebInitiative). */
142
+ export type WebInitiativeLevel = 'off' | 'digest' | 'ask' | 'act';
143
+ /** A kind of thing the page does for the user that may need their go (the double starting a task). */
144
+ export interface WebInitiativeKind {
145
+ /** `<area>.<verb>`: `double.start-task`. */
146
+ id: string;
147
+ title: {
148
+ en: string;
149
+ zh: string;
150
+ };
151
+ /** What it does can be taken back: one that cannot never goes past `ask`. */
152
+ reversible: boolean;
153
+ /** Where it starts. */
154
+ level: WebInitiativeLevel;
155
+ }
156
+ /**
157
+ * How far the page goes on its own with what it does for the user, as an extension that keeps the user's trust
158
+ * answers (WebExtensionAPI.registerInitiative): asked first or not, from what the user answered before. Without one,
159
+ * the settings of the page say.
160
+ */
161
+ export interface WebInitiative {
162
+ /** Where the kind is now; it is defined the first time. */
163
+ level(kind: WebInitiativeKind): Promise<WebInitiativeLevel>;
164
+ /** The user chose, in a setting of the page: kept there; `null` gives it back. */
165
+ setLevel(kind: WebInitiativeKind, level: WebInitiativeLevel | null): Promise<void>;
166
+ /** What the user answered when asked: it moves the level. */
167
+ record(kind: WebInitiativeKind, outcome: 'accepted' | 'declined', title: string): Promise<void>;
168
+ /** A level may have changed. */
169
+ subscribe?(listener: () => void): () => void;
170
+ }
133
171
  /** A conversation of the lists, as a {@link WebChatIconSource} reads it: open, or saved in its file. */
134
172
  export interface WebChat {
135
173
  /** Its file; none for a new one that has said nothing yet. */
@@ -302,6 +340,23 @@ export interface WebToolRenderer {
302
340
  * `next()` is what the resolvers after it would use, so `next() ?? mine` only fills in.
303
341
  */
304
342
  export type WebToolRendererResolver = (toolName: string, next: () => WebToolRenderer | undefined) => WebToolRenderer | undefined;
343
+ /**
344
+ * A conversation that waits for the user to decide (ui.useAsks): its last turn asked and they did not answer or let it
345
+ * go, or a dialog of it waits for an answer.
346
+ */
347
+ export interface WebAsk {
348
+ /** Its session file: `openChat` shows it; the id of its session before it has one. */
349
+ sessionFile: string;
350
+ /** Its session, while it is open. */
351
+ sessionId?: string;
352
+ cwd: string;
353
+ /** As the list of chats names it. */
354
+ title: string;
355
+ /** What it asks, on one line (TaSessionInfo.asking); none for a dialog that waits, whose words are in it. */
356
+ question?: string;
357
+ /** When it asked: the latest first. */
358
+ at: number;
359
+ }
305
360
  /**
306
361
  * A piece of work handed out on the user's behalf. `waiting`: it cannot go on without the user (a question,
307
362
  * its turn in a channel); what has ended is `done`, `failed` or `stopped`.
@@ -356,6 +411,18 @@ export interface WebCodeRendererProps {
356
411
  language: string;
357
412
  /** False while the reply still streams it: the code may stop anywhere. */
358
413
  closed: boolean;
414
+ /**
415
+ * Sends words as the user to the conversation the block is in (after its turn, if it works): a choice in it
416
+ * answered with a tap. None where no conversation holds the block (`ui.Markdown` of a page). Newer than some
417
+ * Ta apps, whose props have no `send`: there `pi.sendUserMessage` reaches the conversation shown.
418
+ */
419
+ send?: (text: string) => Promise<void>;
420
+ /**
421
+ * What the user said after the reply the block is in, once they did: a choice it offers was made (the words sent
422
+ * by `send`, or typed). None while they did not answer, and where no conversation holds the block. Newer than
423
+ * some Ta apps.
424
+ */
425
+ answer?: string;
359
426
  }
360
427
  export interface WebCustomMessage {
361
428
  role: 'custom';
@@ -391,4 +458,56 @@ export interface WebSessionNotice {
391
458
  label: string;
392
459
  run(): void;
393
460
  }[];
461
+ /** What it is about when it is no conversation's (a room asks for a permission): in place of a conversation's name. */
462
+ title?: string;
463
+ /**
464
+ * A view a tap opens (`<extension name>/<view name>`), for news of an extension that is no conversation's: the
465
+ * extension shows it on the page itself, so the page tells of it only by a notice of the system while away.
466
+ */
467
+ view?: string;
468
+ }
469
+ /** Lines and columns of a file, from 1: a line, a place in it, or a range. */
470
+ export interface TextSelection {
471
+ startLine: number;
472
+ startColumn?: number;
473
+ endLine?: number;
474
+ endColumn?: number;
475
+ }
476
+ /**
477
+ * What a link of a reply points to, once the page knows it is there: a file or a directory of `cwd`
478
+ * (`path` relative to it, `''` for `cwd` itself), or a page of the web, opened inside Ta.
479
+ */
480
+ export type WebLink = {
481
+ type: 'file';
482
+ cwd: string;
483
+ path: string;
484
+ selection?: TextSelection;
485
+ } | {
486
+ type: 'directory';
487
+ cwd: string;
488
+ path: string;
489
+ } | {
490
+ type: 'url';
491
+ url: string;
492
+ };
493
+ /** True when it opened the link; false leaves it to the next opener. */
494
+ export type WebOpener = (link: WebLink) => boolean | Promise<boolean>;
495
+ export interface WebOpenerOptions {
496
+ /**
497
+ * It opens some links only, of its own (a link of a share): it is asked before the others, and for links that
498
+ * go out of Ta too (one scanned, opened with Cmd or Ctrl, pasted in Quick open), which the others are not.
499
+ */
500
+ specific?: boolean;
501
+ }
502
+ /** A conversation as a list shows it: an open one has its session, one kept on the disk its file only. */
503
+ export interface WebSessionRef {
504
+ sessionId?: string;
505
+ sessionFile?: string;
506
+ cwd: string;
507
+ /** As the list names it. */
508
+ title: string;
509
+ /** TaSessionInfo.group. */
510
+ group?: string;
394
511
  }
512
+ /** The entries an extension adds to the menu of a conversation of a list (registerSessionMenu); none for some. */
513
+ export type WebSessionMenu = (session: WebSessionRef) => WebMenuItem[];
@@ -7,7 +7,7 @@ import type { GameProps } from '../game/game-protocol.js';
7
7
  import type { Game3DProps } from '../game/game3d-protocol.js';
8
8
  import type { Language, Theme } from '../settings/settings-protocol.js';
9
9
  import type { CodeEditorProps, DiffEditorProps, WebComposerProps, WebDialogProps, WebEmptyProps, WebFaceProps, WebFolderPickerProps, WebFullScreenProps, WebGroupFaceProps, WebHoldToTalkProps, WebImageViewerProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebSkeletonProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebVoice } from './web-api-components.js';
10
- import type { WebChatIconSource, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebHomeEntry, WebHomeSource, WebMenuItem, WebSearchSource, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions.js';
10
+ import type { WebAsk, WebChatIconSource, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebHomeEntry, WebHomeSource, WebInitiative, WebMenuItem, WebOpener, WebOpenerOptions, WebSearchSource, WebSessionMenu, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions.js';
11
11
  import type { WebDesktop, WebFileDrag } from './web-api-desktop.js';
12
12
  import type { WebTerminal, WebTerminalOptions } from './web-api-terminal.js';
13
13
  import type { WebPageInfo } from './web-pages.js';
@@ -83,6 +83,11 @@ export interface WebExtensionAPI {
83
83
  * each day (a daily brief). Newer than some Ta apps: `pi.registerHomeItems?.(…)`.
84
84
  */
85
85
  registerHomeItems(source: WebHomeSource): void;
86
+ /**
87
+ * How far the page goes on its own with what it does for the user (the double starting a task): the extension that
88
+ * keeps the user's trust answers; the first registered is asked. Newer than some Ta apps: `pi.registerInitiative?.(…)`.
89
+ */
90
+ registerInitiative(initiative: WebInitiative): void;
86
91
  /** A tool of the conversations the page opens, run in the browser. */
87
92
  registerTool(tool: WebTool): void;
88
93
  /**
@@ -140,6 +145,11 @@ export interface WebExtensionAPI {
140
145
  * `pi.openChat?.(…)`.
141
146
  */
142
147
  openChat(sessionFile: string): Promise<boolean>;
148
+ /**
149
+ * Opens a link as a click on a link of a reply does: the openers of extensions first (a link of a share, of a
150
+ * card, of an extension), else a page in the browser of the workbench. Newer than some Ta apps: `pi.openLink?.(…)`.
151
+ */
152
+ openLink(url: string): Promise<void>;
143
153
  /**
144
154
  * Calls a method of the server side of the extension's package (`pi.host` of its package.json, which
145
155
  * ta serve runs for the packages that come with Ta), with JSON values: what the page cannot do itself.
@@ -176,51 +186,6 @@ export interface WebExtensionAPI {
176
186
  }
177
187
  /** The rooms of ta serve (TaRoomServer), which the page watches for the extensions that listen (`onRoomEvent`). */
178
188
  export type WebRooms = Omit<TaRoomServer, 'watch' | 'unwatch'>;
179
- /** Lines and columns of a file, from 1: a line, a place in it, or a range. */
180
- export interface TextSelection {
181
- startLine: number;
182
- startColumn?: number;
183
- endLine?: number;
184
- endColumn?: number;
185
- }
186
- /**
187
- * What a link of a reply points to, once the page knows it is there: a file or a directory of `cwd`
188
- * (`path` relative to it, `''` for `cwd` itself), or a page of the web, opened inside Ta.
189
- */
190
- export type WebLink = {
191
- type: 'file';
192
- cwd: string;
193
- path: string;
194
- selection?: TextSelection;
195
- } | {
196
- type: 'directory';
197
- cwd: string;
198
- path: string;
199
- } | {
200
- type: 'url';
201
- url: string;
202
- };
203
- /** True when it opened the link; false leaves it to the next opener. */
204
- export type WebOpener = (link: WebLink) => boolean | Promise<boolean>;
205
- export interface WebOpenerOptions {
206
- /**
207
- * It opens some links only, of its own (a link of a share): it is asked before the others, and for links that
208
- * go out of Ta too (one scanned, opened with Cmd or Ctrl, pasted in Quick open), which the others are not.
209
- */
210
- specific?: boolean;
211
- }
212
- /** A conversation as a list shows it: an open one has its session, one kept on the disk its file only. */
213
- export interface WebSessionRef {
214
- sessionId?: string;
215
- sessionFile?: string;
216
- cwd: string;
217
- /** As the list names it. */
218
- title: string;
219
- /** TaSessionInfo.group. */
220
- group?: string;
221
- }
222
- /** The entries an extension adds to the menu of a conversation of a list (registerSessionMenu); none for some. */
223
- export type WebSessionMenu = (session: WebSessionRef) => WebMenuItem[];
224
189
  /** What a session still opening is shown as (`switchSession`): the head of its conversation, till it comes. */
225
190
  export interface WebSessionOpening {
226
191
  title?: string;
@@ -366,6 +331,12 @@ export interface WebExtensionUI {
366
331
  * `server.listSavedSessions()` again and again. Newer than some Ta apps: `pi.ui.useSavedSessions?.()`.
367
332
  */
368
333
  useSavedSessions(): readonly TaSavedSessionInfo[];
334
+ /**
335
+ * A React hook: the conversations that wait for the user to decide, as the list of chats shows them at its top
336
+ * (TaSessionInfo.asking unless let go, a dialog that waits), the latest first. Newer than some Ta apps:
337
+ * `pi.ui.useAsks?.()`.
338
+ */
339
+ useAsks(): readonly WebAsk[];
369
340
  /**
370
341
  * Shows a view of any web extension by its id, `<extension name>/<view name>` (`assistant/assistant`
371
342
  * for the double): a page in the main area, a tool of the workbench as its tab; `''` the conversation again.
@@ -429,6 +400,12 @@ export interface WebExtensionUI {
429
400
  * it opened; says why not in a notice.
430
401
  */
431
402
  openShared(text: string): Promise<boolean>;
403
+ /**
404
+ * Connects to another Ta by a pairing link (`ta pair`, or the device a Ta that let the user in gave them, docs/design/
405
+ * ta-team.md 8.2), and switches to it once it answered, as adding a computer does: the page loads again. Resolves
406
+ * false (saying why in a notice) when it did not answer or refused. Newer than some Ta apps: `pi.ui.connect?.(…)`.
407
+ */
408
+ connect?(link: string): Promise<boolean>;
432
409
  /** Stops an extension started on open that runs (in the background): it starts again when opened. */
433
410
  stopExtension(name: string): void;
434
411
  /** Takes a page (WebPageInfo.id) out of those used lately. */
@@ -1,4 +1,4 @@
1
- import type { TaSettingsServer } from '@celljs/ta-protocol';
1
+ import { type TaServer, type TaSettingsServer } from '@celljs/ta-protocol';
2
2
  import * as React from 'react';
3
3
  import type { TaFiles } from '../files/files-protocol.js';
4
4
  import type { GameProps } from '../game/game-protocol.js';
@@ -9,6 +9,7 @@ import type { TaSessionNotices } from '../notices/session-notices.js';
9
9
  import type { TaSettings } from '../settings/settings-protocol.js';
10
10
  import type { TaState } from '../state/state-protocol.js';
11
11
  import type { TaWorkbench } from '../workbench-protocol.js';
12
+ import type { WebCodeRendererProps } from './web-api-contributions.js';
12
13
  import type { WebEditorTabs } from './web-editor-tabs.js';
13
14
  import type { CodeEditorProps, DiffEditorProps, WebComposerProps, WebExtensionAPI, WebExtensionUI, WebFolderPickerProps, WebHoldToTalkProps, WebModelPickerProps, WebStorage, WebViewInfo, WebVoice } from './web-extension-api.js';
14
15
  import { type TaWebExtensions, type WebExtensionConversation, type WebSessionSwitcher } from './web-extension-protocol.js';
@@ -45,6 +46,10 @@ export interface WebExtensionContextHost {
45
46
  export declare class WebExtensionContext {
46
47
  protected readonly host: WebExtensionContextHost;
47
48
  constructor(host: WebExtensionContextHost);
49
+ /** The server, whose messages for a conversation say they came from the extension. */
50
+ static marked(server: TaServer, mark: (text: string) => string): TaServer;
51
+ /** A renderer of code whose `send` (a choice tapped in it) says it came from the extension. */
52
+ static replying(Renderer: React.ComponentType<WebCodeRendererProps>, mark: (text: string) => string): React.ComponentType<WebCodeRendererProps>;
48
53
  /** Monaco and the games in the theme and language of the settings, the same component for every extension. */
49
54
  protected readonly codeEditor: (props: CodeEditorProps) => React.FunctionComponentElement<CodeEditorProps & {
50
55
  settings: TaSettings;
@@ -1,5 +1,7 @@
1
+ import { TaMessageSource, } from '@celljs/ta-protocol';
1
2
  import * as React from 'react';
2
3
  import { useBusy } from '../components/busy.js';
4
+ import { ChatAskUtil, LET_GO_ASKS } from '../components/chat-asks.js';
3
5
  import { PINNED } from '../components/chat-list.js';
4
6
  import { CodeEditor } from '../components/code-editor.js';
5
7
  import { ContextMenuUtil, useContextMenu } from '../components/context-menu.js';
@@ -78,6 +80,27 @@ export class WebExtensionContext {
78
80
  onClose,
79
81
  }); };
80
82
  }
83
+ /** The server, whose messages for a conversation say they came from the extension. */
84
+ static marked(server, mark) {
85
+ const sending = new Set(['prompt', 'steer', 'followUp']);
86
+ return new Proxy(server, {
87
+ get(target, property, receiver) {
88
+ const value = Reflect.get(target, property, receiver);
89
+ if (!sending.has(property) || typeof value !== 'function') {
90
+ return value;
91
+ }
92
+ return (sessionId, input) => value.call(target, sessionId, { ...input, message: mark(input.message) });
93
+ },
94
+ });
95
+ }
96
+ /** A renderer of code whose `send` (a choice tapped in it) says it came from the extension. */
97
+ static replying(Renderer, mark) {
98
+ return function Replying(props) {
99
+ const { send } = props;
100
+ const marked = React.useMemo(() => send && ((text) => send(mark(text))), [send]);
101
+ return React.createElement(Renderer, { ...props, send: marked });
102
+ };
103
+ }
81
104
  create(run) {
82
105
  const { host } = this;
83
106
  const { workbench, files } = host;
@@ -91,10 +114,16 @@ export class WebExtensionContext {
91
114
  };
92
115
  /** What acts for the user: refused once the extension stopped. */
93
116
  const live = (action) => run.stopped ? Promise.reject(new Error(`The web extension ${run.loaded.name} has stopped.`)) : action();
117
+ // What it sends as the user says it came from this package (TaMessageSource): a page shows so.
118
+ const mark = (text) => TaMessageSource.mark(text, run.loaded.name);
119
+ let server;
94
120
  return {
95
121
  React,
96
122
  get server() {
97
- return workbench.server;
123
+ if ((server === null || server === void 0 ? void 0 : server.of) !== workbench.server) {
124
+ server = { of: workbench.server, marked: WebExtensionContext.marked(workbench.server, mark) };
125
+ }
126
+ return server.marked;
98
127
  },
99
128
  get workspace() {
100
129
  return workbench.workspace;
@@ -123,7 +152,7 @@ export class WebExtensionContext {
123
152
  storage: { ...this.storage(run), directory: cwd => this.storage(run, cwd) },
124
153
  registerView: (name, view) => register(() => run.views.set(name, view)),
125
154
  registerMessageRenderer: (customType, renderer) => register(() => run.renderers.set(customType, renderer)),
126
- registerCodeRenderer: (language, renderer) => register(() => run.codeRenderers.set(language.trim().toLowerCase(), renderer)),
155
+ registerCodeRenderer: (language, renderer) => register(() => run.codeRenderers.set(language.trim().toLowerCase(), WebExtensionContext.replying(renderer, mark))),
127
156
  registerAvatar: avatar => register(() => {
128
157
  run.avatar = avatar;
129
158
  }),
@@ -132,6 +161,7 @@ export class WebExtensionContext {
132
161
  registerToolRenderer: resolver => register(() => run.toolRenderers.push(resolver)),
133
162
  registerTasks: source => register(() => run.taskSources.push(source)),
134
163
  registerHomeItems: source => register(() => run.homeSources.push(source)),
164
+ registerInitiative: initiative => register(() => run.initiatives.push(initiative)),
135
165
  registerSearch: source => register(() => run.searches.push(source)),
136
166
  registerComposerAddon: addon => register(() => run.composerAddons.push(addon)),
137
167
  registerSettings: section => register(() => run.settingsSections.push(section)),
@@ -161,7 +191,7 @@ export class WebExtensionContext {
161
191
  if (!send) {
162
192
  throw new Error('No conversation is shown yet.');
163
193
  }
164
- await send(text);
194
+ await send(mark(text));
165
195
  }),
166
196
  switchSession: (session, opening) => live(async () => {
167
197
  const switcher = host.switcher();
@@ -173,6 +203,7 @@ export class WebExtensionContext {
173
203
  await shown;
174
204
  }),
175
205
  openChat: sessionFile => live(() => host.links.openConversation(sessionFile)),
206
+ openLink: url => live(() => host.links.open({ type: 'url', url })),
176
207
  openTemporary: (source, from) => live(() => host.extensions.openTemporary(source, from)),
177
208
  callHost: (method, ...params) => live(() => workbench.packages.callPackageHost(run.loaded.name, method, params)),
178
209
  reloadExtensions: () => live(() => host.extensions.reloadPackages()),
@@ -241,6 +272,13 @@ export class WebExtensionContext {
241
272
  const saved = () => workbench.state.saved;
242
273
  return React.useSyncExternalStore(listener => workbench.subscribe(listener), saved, saved);
243
274
  },
275
+ useAsks: () => {
276
+ const read = () => workbench.state;
277
+ const { sessions, saved } = React.useSyncExternalStore(listener => workbench.subscribe(listener), read, read);
278
+ const letGo = () => host.persisted.get(LET_GO_ASKS);
279
+ const kept = React.useSyncExternalStore(listener => host.persisted.subscribe(listener), letGo, letGo);
280
+ return React.useMemo(() => ChatAskUtil.list(sessions, saved, kept), [sessions, saved, kept]);
281
+ },
244
282
  useDevice,
245
283
  showView: id => (run.stopped ? Promise.resolve(false) : host.extensions.showView(id)),
246
284
  usePages: () => {
@@ -256,12 +294,28 @@ export class WebExtensionContext {
256
294
  return [menu, openSections];
257
295
  },
258
296
  attachMenu: ContextMenuUtil.attach,
259
- scanCode: Scanner.available() ? instructions => Scanner.scan(instructions, messageOf(settings.state.language, 'ta.cancel')) : undefined,
297
+ scanCode: Scanner.available()
298
+ ? instructions => (run.stopped ? Promise.resolve(undefined) : Scanner.scan(instructions, messageOf(settings.state.language, 'ta.cancel')))
299
+ : undefined,
260
300
  scan: CodeScan.available() ? () => (run.stopped ? Promise.resolve() : new CodeScan(host).scan()) : undefined,
261
301
  stopExtension: name => !run.stopped && host.extensions.stopExtension(name),
262
302
  shareExtension: target => !run.stopped && host.extensions.share(target),
263
303
  custom: component => WebExtensionRunUtil.track(run, () => host.extensions.showCustom(run.loaded.name, component)),
264
304
  openShared: text => (run.stopped ? Promise.resolve(false) : host.extensions.openShared(text)),
305
+ connect: async (link) => {
306
+ if (run.stopped) {
307
+ return false;
308
+ }
309
+ try {
310
+ await host.workbench.signIn(link);
311
+ return true;
312
+ }
313
+ catch (failure) {
314
+ const refused = (failure === null || failure === void 0 ? void 0 : failure.reason) === 'refused';
315
+ notices.notify(messageOf(settings.state.language, refused ? 'ta.hosts.refused' : 'ta.hosts.unreachable'), { level: 'error' });
316
+ return false;
317
+ }
318
+ },
265
319
  forgetPage: id => !run.stopped && host.extensions.forgetPage(id),
266
320
  useTasks: () => React.useSyncExternalStore(host.extensions.tasks.subscribe, host.extensions.tasks.tasks, host.extensions.tasks.tasks),
267
321
  useHomeItems: () => React.useSyncExternalStore(host.extensions.home.subscribe, host.extensions.home.items, host.extensions.home.items),
@@ -271,10 +325,13 @@ export class WebExtensionContext {
271
325
  icons: WEB_ICONS,
272
326
  CodeEditor: this.codeEditor,
273
327
  DiffEditor: this.diffEditor,
274
- // Ends with the extension.
328
+ // Ends with the extension: one made after it stopped is ended at once.
275
329
  createTerminal: (options) => {
276
330
  const terminal = new DefaultWebTerminal(settings, (target, open) => void host.links.open(target, open), options);
277
- run.unsubscribes.push(() => terminal.dispose());
331
+ WebExtensionRunUtil.track(run, () => () => terminal.dispose());
332
+ if (run.stopped) {
333
+ terminal.dispose();
334
+ }
278
335
  return terminal;
279
336
  },
280
337
  Game: this.game,
@@ -1,7 +1,7 @@
1
1
  import type { TaEvent, TaTemporaryFrom, TaWebExtensionInfo } from '@celljs/ta-protocol';
2
2
  import type * as React from 'react';
3
3
  import type { MessageId } from '../i18n/messages.js';
4
- import type { WebAvatarProps, WebChatIconSource, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebExtensionFactory, WebIcon, WebImage, WebLabel, WebMenuItem, WebOpener, WebSearchSource, WebSessionMenu, WebSessionOpening, WebSettingsSection, WebShareTarget, WebTool, WebToolRendererResolver, WebViewLocation, WebViewPreview, WidgetOptions } from './web-extension-api.js';
4
+ import type { WebAvatarProps, WebChatIconSource, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebExtensionFactory, WebIcon, WebImage, WebInitiative, WebLabel, WebMenuItem, WebOpener, WebSearchSource, WebSessionMenu, WebSessionOpening, WebSettingsSection, WebShareTarget, WebTool, WebToolRendererResolver, WebViewLocation, WebViewPreview, WidgetOptions } from './web-extension-api.js';
5
5
  import type { WebHomeBoard } from './web-home.js';
6
6
  import type { PageUsage, WebPageInfo } from './web-pages.js';
7
7
  import type { WebTaskBoard } from './web-tasks.js';
@@ -62,6 +62,8 @@ export interface WebViewEntry {
62
62
  discover?: boolean;
63
63
  menu?(): WebMenuItem[][];
64
64
  preview?(): WebViewPreview | undefined;
65
+ /** WebView.mark. */
66
+ mark?: React.ComponentType;
65
67
  busy?(): boolean;
66
68
  subscribePreview?(listener: () => void): () => void;
67
69
  send?(text: string, images?: WebImage[]): Promise<void>;
@@ -113,6 +115,8 @@ export interface WebExtensionsState {
113
115
  avatars: Record<string, React.ComponentType<WebAvatarProps>>;
114
116
  /** The icons extensions give conversations of theirs (WebExtensionAPI.registerChatIcon), with the extension of each. */
115
117
  chatIcons: WebChatIconEntry[];
118
+ /** What answers how far the page goes on its own (WebExtensionAPI.registerInitiative), in the order registered. */
119
+ initiatives: WebInitiative[];
116
120
  /** The first tool of each name. */
117
121
  tools: WebTool[];
118
122
  /** How calls of tools read (WebExtensionAPI.registerToolRenderer), in the order the extensions loaded. */
@@ -14,6 +14,7 @@ export var WebExtensionsStateUtil;
14
14
  codeRenderers: {},
15
15
  avatars: {},
16
16
  chatIcons: [],
17
+ initiatives: [],
17
18
  tools: [],
18
19
  toolRenderers: [],
19
20
  openers: [],
@@ -1,6 +1,6 @@
1
1
  import type { TaEvent } from '@celljs/ta-protocol';
2
2
  import type * as React from 'react';
3
- import type { WebChatIconSource, WebComposerAddon, WebHomeSource, WebOpener, WebSearchSource, WebSessionMenu, WebSettingsSection, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WidgetOptions } from './web-extension-api.js';
3
+ import type { WebChatIconSource, WebComposerAddon, WebHomeSource, WebInitiative, WebOpener, WebSearchSource, WebSessionMenu, WebSettingsSection, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WidgetOptions } from './web-extension-api.js';
4
4
  import type { LoadedWebExtension, WebExtensionsState } from './web-extension-protocol.js';
5
5
  /** What an extension registered through its API: all of it goes when it stops. */
6
6
  export interface WebRegistrations {
@@ -14,6 +14,7 @@ export interface WebRegistrations {
14
14
  avatar?: WebExtensionsState['avatars'][string];
15
15
  chatIcons: WebChatIconSource[];
16
16
  homeSources: WebHomeSource[];
17
+ initiatives: WebInitiative[];
17
18
  tools: WebTool[];
18
19
  toolRenderers: WebToolRendererResolver[];
19
20
  openers: WebOpener[];
@@ -50,5 +51,5 @@ export declare namespace WebExtensionRunUtil {
50
51
  /** Subscribes for the extension: undone when it stops, or by the function returned. */
51
52
  function track(run: WebExtensionRun, subscribe: () => () => void): () => void;
52
53
  /** What the extensions that run registered, as the page shows it: the first of a message type or a tool name wins. */
53
- function collect(runs: readonly WebExtensionRun[], onOpen: (id: string) => boolean): Pick<WebExtensionsState, 'openers' | 'specificOpeners' | 'sessionMenus' | 'extensions' | 'views' | 'widgets' | 'composerAddons' | 'settingsSections' | 'renderers' | 'codeRenderers' | 'avatars' | 'chatIcons' | 'tools' | 'toolRenderers' | 'searches'>;
54
+ function collect(runs: readonly WebExtensionRun[], onOpen: (id: string) => boolean): Pick<WebExtensionsState, 'openers' | 'specificOpeners' | 'sessionMenus' | 'extensions' | 'views' | 'widgets' | 'composerAddons' | 'settingsSections' | 'renderers' | 'codeRenderers' | 'avatars' | 'chatIcons' | 'initiatives' | 'tools' | 'toolRenderers' | 'searches'>;
54
55
  }
@@ -11,6 +11,7 @@ export var WebExtensionRunUtil;
11
11
  avatar: undefined,
12
12
  chatIcons: [],
13
13
  homeSources: [],
14
+ initiatives: [],
14
15
  tools: [],
15
16
  toolRenderers: [],
16
17
  openers: [],
@@ -86,6 +87,7 @@ export var WebExtensionRunUtil;
86
87
  discover: view.discover,
87
88
  menu: (_a = view.menu) === null || _a === void 0 ? void 0 : _a.bind(view),
88
89
  preview: (_b = view.preview) === null || _b === void 0 ? void 0 : _b.bind(view),
90
+ mark: view.mark,
89
91
  busy: (_c = view.busy) === null || _c === void 0 ? void 0 : _c.bind(view),
90
92
  subscribePreview: (_d = view.subscribe) === null || _d === void 0 ? void 0 : _d.bind(view),
91
93
  send: (_e = view.send) === null || _e === void 0 ? void 0 : _e.bind(view),
@@ -110,6 +112,7 @@ export var WebExtensionRunUtil;
110
112
  codeRenderers,
111
113
  avatars,
112
114
  chatIcons: runs.flatMap(run => run.chatIcons.map(source => ({ extension: run.loaded.name, source }))),
115
+ initiatives: runs.flatMap(run => run.initiatives),
113
116
  tools,
114
117
  toolRenderers: runs.flatMap(run => run.toolRenderers),
115
118
  searches: runs.flatMap(run => run.searches).sort((a, b) => { var _a, _b; return ((_a = a.order) !== null && _a !== void 0 ? _a : DEFAULT_ORDER) - ((_b = b.order) !== null && _b !== void 0 ? _b : DEFAULT_ORDER); }),