@celljs/ta-web 4.45.1 → 4.46.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 (165) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/account/device-account.d.ts +15 -8
  4. package/esm/browser/account/device-account.js +40 -4
  5. package/esm/browser/assistant/assistant-view.js +8 -8
  6. package/esm/browser/assistant/assistant.d.ts +3 -1
  7. package/esm/browser/assistant/assistant.js +10 -4
  8. package/esm/browser/chat/chat-stores.d.ts +1 -3
  9. package/esm/browser/chat/chat-stores.js +3 -18
  10. package/esm/browser/chat/chat-view.js +9 -3
  11. package/esm/browser/chat/web-client-tools.d.ts +15 -0
  12. package/esm/browser/chat/web-client-tools.js +35 -0
  13. package/esm/browser/components/account-view.js +7 -4
  14. package/esm/browser/components/app-shell-hooks.js +2 -1
  15. package/esm/browser/components/cloud-sign-in-view.d.ts +3 -2
  16. package/esm/browser/components/cloud-sign-in-view.js +11 -3
  17. package/esm/browser/components/composer-addon-util.d.ts +3 -1
  18. package/esm/browser/components/composer-addon-util.js +22 -0
  19. package/esm/browser/components/composer-addons.d.ts +2 -1
  20. package/esm/browser/components/composer-addons.js +1 -1
  21. package/esm/browser/components/hero-cards-util.d.ts +15 -0
  22. package/esm/browser/components/hero-cards-util.js +25 -0
  23. package/esm/browser/components/hero-cards.d.ts +13 -3
  24. package/esm/browser/components/hero-cards.js +41 -11
  25. package/esm/browser/components/host-view.d.ts +1 -1
  26. package/esm/browser/components/host-view.js +2 -1
  27. package/esm/browser/components/profile-view.js +31 -1
  28. package/esm/browser/components/recent-shots-access.d.ts +9 -0
  29. package/esm/browser/components/recent-shots-access.js +29 -0
  30. package/esm/browser/components/relay-view.js +20 -0
  31. package/esm/browser/components/settings-more.js +2 -1
  32. package/esm/browser/components/settings-parts.js +5 -2
  33. package/esm/browser/components/workbench-tabs.js +1 -1
  34. package/esm/browser/components/workbench-view.js +3 -5
  35. package/esm/browser/device/hold.d.ts +5 -2
  36. package/esm/browser/device/hold.js +7 -4
  37. package/esm/browser/extension/icons.js +2 -1
  38. package/esm/browser/extension/web-api-composer.d.ts +51 -0
  39. package/esm/browser/extension/web-api-composer.js +2 -0
  40. package/esm/browser/extension/web-api-contributions.d.ts +5 -33
  41. package/esm/browser/extension/web-api-desktop.d.ts +5 -0
  42. package/esm/browser/extension/web-api-spec.js +1 -0
  43. package/esm/browser/extension/web-extension-context.js +6 -0
  44. package/esm/browser/i18n/en/account.d.ts +1 -0
  45. package/esm/browser/i18n/en/account.js +2 -1
  46. package/esm/browser/i18n/en/assistant.d.ts +1 -0
  47. package/esm/browser/i18n/en/assistant.js +1 -0
  48. package/esm/browser/i18n/en/chat.d.ts +1 -0
  49. package/esm/browser/i18n/en/chat.js +1 -0
  50. package/esm/browser/i18n/en/service.d.ts +2 -0
  51. package/esm/browser/i18n/en/service.js +2 -0
  52. package/esm/browser/i18n/en/settings.d.ts +5 -0
  53. package/esm/browser/i18n/en/settings.js +5 -0
  54. package/esm/browser/i18n/ja/account.js +2 -1
  55. package/esm/browser/i18n/ja/assistant.js +1 -0
  56. package/esm/browser/i18n/ja/chat.js +1 -0
  57. package/esm/browser/i18n/ja/service.js +2 -0
  58. package/esm/browser/i18n/ja/settings.js +5 -0
  59. package/esm/browser/i18n/locales.d.ts +11 -1
  60. package/esm/browser/i18n/messages.d.ts +10 -0
  61. package/esm/browser/i18n/zh/account.js +2 -1
  62. package/esm/browser/i18n/zh/assistant.js +1 -0
  63. package/esm/browser/i18n/zh/chat.js +1 -0
  64. package/esm/browser/i18n/zh/service.js +2 -0
  65. package/esm/browser/i18n/zh/settings.js +5 -0
  66. package/esm/browser/i18n/zh-tw/account.js +2 -1
  67. package/esm/browser/i18n/zh-tw/assistant.js +1 -0
  68. package/esm/browser/i18n/zh-tw/chat.js +1 -0
  69. package/esm/browser/i18n/zh-tw/service.js +2 -0
  70. package/esm/browser/i18n/zh-tw/settings.js +5 -0
  71. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  72. package/esm/browser/share/shared-page.js +3 -5
  73. package/esm/browser/style/chat-list.d.ts +1 -1
  74. package/esm/browser/style/chat-list.js +2 -0
  75. package/esm/browser/style/layout.d.ts +1 -1
  76. package/esm/browser/style/layout.js +5 -2
  77. package/esm/browser/style/pages.d.ts +1 -1
  78. package/esm/browser/style/pages.js +6 -0
  79. package/esm/browser/style.d.ts +10 -0
  80. package/esm/browser/style.js +35 -0
  81. package/esm/browser/util/desktop.d.ts +9 -0
  82. package/esm/browser/util/desktop.js +5 -1
  83. package/esm/browser/video-call/call-window.js +2 -4
  84. package/lib/browser/account/device-account.d.ts +15 -8
  85. package/lib/browser/account/device-account.js +40 -4
  86. package/lib/browser/assistant/assistant-view.js +7 -7
  87. package/lib/browser/assistant/assistant.d.ts +3 -1
  88. package/lib/browser/assistant/assistant.js +10 -4
  89. package/lib/browser/chat/chat-stores.d.ts +1 -3
  90. package/lib/browser/chat/chat-stores.js +3 -18
  91. package/lib/browser/chat/chat-view.js +8 -2
  92. package/lib/browser/chat/web-client-tools.d.ts +16 -0
  93. package/lib/browser/chat/web-client-tools.js +38 -0
  94. package/lib/browser/components/account-view.js +7 -4
  95. package/lib/browser/components/app-shell-hooks.js +2 -1
  96. package/lib/browser/components/cloud-sign-in-view.d.ts +3 -2
  97. package/lib/browser/components/cloud-sign-in-view.js +10 -2
  98. package/lib/browser/components/composer-addon-util.d.ts +3 -1
  99. package/lib/browser/components/composer-addon-util.js +22 -0
  100. package/lib/browser/components/composer-addons.d.ts +2 -1
  101. package/lib/browser/components/composer-addons.js +1 -1
  102. package/lib/browser/components/hero-cards-util.d.ts +16 -0
  103. package/lib/browser/components/hero-cards-util.js +28 -0
  104. package/lib/browser/components/hero-cards.d.ts +13 -3
  105. package/lib/browser/components/hero-cards.js +43 -11
  106. package/lib/browser/components/host-view.d.ts +1 -1
  107. package/lib/browser/components/host-view.js +2 -1
  108. package/lib/browser/components/profile-view.js +30 -0
  109. package/lib/browser/components/recent-shots-access.d.ts +10 -0
  110. package/lib/browser/components/recent-shots-access.js +65 -0
  111. package/lib/browser/components/relay-view.js +20 -0
  112. package/lib/browser/components/settings-more.js +2 -1
  113. package/lib/browser/components/settings-parts.js +5 -2
  114. package/lib/browser/components/workbench-tabs.js +1 -1
  115. package/lib/browser/components/workbench-view.js +2 -4
  116. package/lib/browser/device/hold.d.ts +5 -2
  117. package/lib/browser/device/hold.js +7 -4
  118. package/lib/browser/extension/icons.js +1 -0
  119. package/lib/browser/extension/web-api-composer.d.ts +52 -0
  120. package/lib/browser/extension/web-api-composer.js +3 -0
  121. package/lib/browser/extension/web-api-contributions.d.ts +5 -33
  122. package/lib/browser/extension/web-api-desktop.d.ts +5 -0
  123. package/lib/browser/extension/web-api-spec.js +1 -0
  124. package/lib/browser/extension/web-extension-context.js +6 -0
  125. package/lib/browser/i18n/en/account.d.ts +1 -0
  126. package/lib/browser/i18n/en/account.js +2 -1
  127. package/lib/browser/i18n/en/assistant.d.ts +1 -0
  128. package/lib/browser/i18n/en/assistant.js +1 -0
  129. package/lib/browser/i18n/en/chat.d.ts +1 -0
  130. package/lib/browser/i18n/en/chat.js +1 -0
  131. package/lib/browser/i18n/en/service.d.ts +2 -0
  132. package/lib/browser/i18n/en/service.js +2 -0
  133. package/lib/browser/i18n/en/settings.d.ts +5 -0
  134. package/lib/browser/i18n/en/settings.js +5 -0
  135. package/lib/browser/i18n/ja/account.js +2 -1
  136. package/lib/browser/i18n/ja/assistant.js +1 -0
  137. package/lib/browser/i18n/ja/chat.js +1 -0
  138. package/lib/browser/i18n/ja/service.js +2 -0
  139. package/lib/browser/i18n/ja/settings.js +5 -0
  140. package/lib/browser/i18n/locales.d.ts +11 -1
  141. package/lib/browser/i18n/messages.d.ts +10 -0
  142. package/lib/browser/i18n/zh/account.js +2 -1
  143. package/lib/browser/i18n/zh/assistant.js +1 -0
  144. package/lib/browser/i18n/zh/chat.js +1 -0
  145. package/lib/browser/i18n/zh/service.js +2 -0
  146. package/lib/browser/i18n/zh/settings.js +5 -0
  147. package/lib/browser/i18n/zh-tw/account.js +2 -1
  148. package/lib/browser/i18n/zh-tw/assistant.js +1 -0
  149. package/lib/browser/i18n/zh-tw/chat.js +1 -0
  150. package/lib/browser/i18n/zh-tw/service.js +2 -0
  151. package/lib/browser/i18n/zh-tw/settings.js +5 -0
  152. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  153. package/lib/browser/share/shared-page.js +2 -4
  154. package/lib/browser/style/chat-list.d.ts +1 -1
  155. package/lib/browser/style/chat-list.js +2 -0
  156. package/lib/browser/style/layout.d.ts +1 -1
  157. package/lib/browser/style/layout.js +5 -2
  158. package/lib/browser/style/pages.d.ts +1 -1
  159. package/lib/browser/style/pages.js +6 -0
  160. package/lib/browser/style.d.ts +10 -0
  161. package/lib/browser/style.js +36 -1
  162. package/lib/browser/util/desktop.d.ts +9 -0
  163. package/lib/browser/util/desktop.js +5 -1
  164. package/lib/browser/video-call/call-window.js +1 -3
  165. package/package.json +7 -7
@@ -76,7 +76,16 @@ export interface DesktopShots {
76
76
  read(id: string): Promise<string | undefined>;
77
77
  /** Called when a screenshot may have been taken; returns what stops it. */
78
78
  onChange(listener: () => void): () => void;
79
+ /**
80
+ * Whether the folder of the screenshots may be read: `ask` until the user allowed it where macOS guards it (the
81
+ * Desktop), `denied` when macOS refused. None from a Ta Desktop of before, which reads it at once.
82
+ */
83
+ access?(): Promise<DesktopPlaceAccess>;
84
+ /** The user allows that folder: macOS asks now; refused before, its settings open. */
85
+ allow?(): Promise<DesktopPlaceAccess>;
79
86
  }
87
+ /** What Ta Desktop may do with a folder macOS guards (PlaceAccess of apps/ta-desktop). */
88
+ export type DesktopPlaceAccess = 'ready' | 'ask' | 'denied';
80
89
  /**
81
90
  * A notice of the system Ta Desktop showed while its window was closed, hidden or minimized (its page tells of
82
91
  * none then): tapped, what it is of, for the page to open.
@@ -169,14 +169,18 @@ export var DesktopUtil;
169
169
  function recentShots(scope = globalThis) {
170
170
  var _a;
171
171
  const shots = (_a = scope.taDesktop) === null || _a === void 0 ? void 0 : _a.recentShots;
172
- const { latest, read, onChange } = shots !== null && shots !== void 0 ? shots : {};
172
+ const { latest, read, onChange, access, allow } = shots !== null && shots !== void 0 ? shots : {};
173
173
  if (!has('recentShots', scope) || typeof latest !== 'function' || typeof read !== 'function' || typeof onChange !== 'function') {
174
174
  return undefined;
175
175
  }
176
+ const place = (state) => (state === 'ask' || state === 'denied' ? state : 'ready');
176
177
  return Object.freeze({
177
178
  latest: async () => { var _a; return (_a = (await latest())) !== null && _a !== void 0 ? _a : undefined; },
178
179
  read: async (id) => { var _a; return (_a = (await read(id))) !== null && _a !== void 0 ? _a : undefined; },
179
180
  onChange: (listener) => onChange(listener),
181
+ ...(typeof access === 'function' && typeof allow === 'function'
182
+ ? { access: async () => place(await access()), allow: async () => place(await allow()) }
183
+ : {}),
180
184
  });
181
185
  }
182
186
  DesktopUtil.recentShots = recentShots;
@@ -1,4 +1,4 @@
1
- import { STYLE } from '../style.js';
1
+ import { PageStyle } from '../style.js';
2
2
  import { DesktopUtil } from '../util/desktop.js';
3
3
  /** The name of the window of a video call, which Ta Desktop lets the page open (DesktopChannel.VIDEO_CALL_FRAME). */
4
4
  const FRAME = 'ta-video-call';
@@ -27,9 +27,7 @@ export var CallWindow;
27
27
  current = opened;
28
28
  const doc = opened.document;
29
29
  doc.title = title;
30
- const style = doc.createElement('style');
31
- style.textContent = STYLE;
32
- doc.head.appendChild(style);
30
+ PageStyle.attach(doc);
33
31
  // As the page looks, and as it changes (the theme, the size of the text).
34
32
  const root = document.documentElement;
35
33
  const look = () => {
@@ -38,6 +38,11 @@ export interface RecentAccount {
38
38
  hosts: SavedHost[];
39
39
  at: number;
40
40
  }
41
+ interface Joining {
42
+ hosts: string[];
43
+ devices: string[];
44
+ through?: string;
45
+ }
41
46
  /**
42
47
  * The app as a device of the user's account (docs/design/ta-account.md): its own keys in localStorage; the computers
43
48
  * of the account come into its list of computers as they let it in, and go as they are removed. The same agent as a
@@ -63,14 +68,13 @@ export declare class DeviceAccount implements AccountSide {
63
68
  protected running?: Promise<void>;
64
69
  protected constructor(hosts: AccountHosts, service: () => Promise<string>, gateways: () => Promise<string[]>);
65
70
  /** The computers to bring into the account, and the devices of it this device lets in once they ask. */
66
- protected static joining(): {
67
- hosts: string[];
68
- devices: string[];
69
- };
70
- protected static keepJoining(next: {
71
- hosts: string[];
72
- devices: string[];
73
- }): void;
71
+ protected static joining(): Joining;
72
+ protected static keepJoining(next: Joining): void;
73
+ /**
74
+ * Whether a device signed out signs in to the account of the computer it just connected to by its code: the
75
+ * computer is in one and lets its scanned phones in (TaAccountInfo.onScan, a switch of the user there).
76
+ */
77
+ static follows(there: TaAccountInfo): boolean;
74
78
  /**
75
79
  * A computer connected by its code while this device is in an account (docs/design/ta-me.md 4): it joins the account
76
80
  * once connected, with a token of the account this device gets for it, and this device lets it in. Being by the
@@ -84,6 +88,8 @@ export declare class DeviceAccount implements AccountSide {
84
88
  protected bringCloud(): void;
85
89
  /** The computer in use, if it waits to be brought into the account: asked to join it. */
86
90
  protected bringPending(): Promise<void>;
91
+ /** Signs in as the computer in use is, connected by its code while signed out, if it lets its scanned phones in. */
92
+ protected follow(joining: Joining): Promise<void>;
87
93
  /** The computers this device brought in, let in as soon as they ask. */
88
94
  protected letInBrought(view: AccountView): Promise<AccountView>;
89
95
  /**
@@ -139,4 +145,5 @@ export declare class DeviceAccount implements AccountSide {
139
145
  remove(id: string): Promise<TaAccountInfo>;
140
146
  signOut(): Promise<TaAccountInfo>;
141
147
  }
148
+ export {};
142
149
  //# sourceMappingURL=device-account.d.ts.map
@@ -9,7 +9,10 @@ const OFF_KEY = 'ta.account.off';
9
9
  /** The accounts switched away from, the latest first. */
10
10
  const RECENT_KEY = 'ta.account.recent';
11
11
  const MAX_RECENT = 5;
12
- /** The computers connected by their code while signed in, to bring into the account once connected: by host id. */
12
+ /**
13
+ * The computers connected by their code while signed in, to bring into the account once connected, by host id; and
14
+ * `through`, the one connected while signed out, whose account this device signs in to once connected if it says so.
15
+ */
13
16
  const JOINING_KEY = 'ta.account.joining';
14
17
  const SYNC_MS = 15000;
15
18
  const WAITING_SYNC_MS = 3000;
@@ -40,7 +43,7 @@ class DeviceAccount {
40
43
  var _b, _c, _d;
41
44
  try {
42
45
  const kept = JSON.parse((_b = (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.getItem(JOINING_KEY)) !== null && _b !== void 0 ? _b : '{}');
43
- return { hosts: (_c = kept.hosts) !== null && _c !== void 0 ? _c : [], devices: (_d = kept.devices) !== null && _d !== void 0 ? _d : [] };
46
+ return { hosts: (_c = kept.hosts) !== null && _c !== void 0 ? _c : [], devices: (_d = kept.devices) !== null && _d !== void 0 ? _d : [], ...(typeof kept.through === 'string' ? { through: kept.through } : {}) };
44
47
  }
45
48
  catch (_e) {
46
49
  return { hosts: [], devices: [] };
@@ -48,7 +51,14 @@ class DeviceAccount {
48
51
  }
49
52
  static keepJoining(next) {
50
53
  var _a;
51
- (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(JOINING_KEY, JSON.stringify({ hosts: next.hosts.slice(-10), devices: next.devices.slice(-10) }));
54
+ (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(JOINING_KEY, JSON.stringify({ hosts: next.hosts.slice(-10), devices: next.devices.slice(-10), through: next.through }));
55
+ }
56
+ /**
57
+ * Whether a device signed out signs in to the account of the computer it just connected to by its code: the
58
+ * computer is in one and lets its scanned phones in (TaAccountInfo.onScan, a switch of the user there).
59
+ */
60
+ static follows(there) {
61
+ return Boolean(there.account) && !there.waiting && there.onScan === true;
52
62
  }
53
63
  /**
54
64
  * A computer connected by its code while this device is in an account (docs/design/ta-me.md 4): it joins the account
@@ -57,7 +67,13 @@ class DeviceAccount {
57
67
  */
58
68
  bringIn(hostId) {
59
69
  var _a;
60
- if (!this.agent || this.tried.has(hostId) || ((_a = this.hosts.state.hosts.find(one => one.id === hostId)) === null || _a === void 0 ? void 0 : _a.account)) {
70
+ if (!this.agent) {
71
+ // Signed out: signs in as that computer is once connected, if it says so (docs/design/ta-account.md 4.4).
72
+ DeviceAccount.keepJoining({ ...DeviceAccount.joining(), through: hostId });
73
+ void this.bringPending();
74
+ return;
75
+ }
76
+ if (this.tried.has(hostId) || ((_a = this.hosts.state.hosts.find(one => one.id === hostId)) === null || _a === void 0 ? void 0 : _a.account)) {
61
77
  return;
62
78
  }
63
79
  const joining = DeviceAccount.joining();
@@ -80,6 +96,10 @@ class DeviceAccount {
80
96
  const { host, status, switching } = this.hosts.state;
81
97
  const joining = DeviceAccount.joining();
82
98
  const agent = this.agent;
99
+ if (!agent && !this.bringing && !switching && host && status === 'online' && joining.through === host) {
100
+ await this.follow(joining);
101
+ return;
102
+ }
83
103
  if (this.bringing || switching || !agent || !host || status !== 'online' || !joining.hosts.includes(host) || !this.view || this.view.waiting) {
84
104
  return;
85
105
  }
@@ -112,6 +132,22 @@ class DeviceAccount {
112
132
  this.bringing = false;
113
133
  }
114
134
  }
135
+ /** Signs in as the computer in use is, connected by its code while signed out, if it lets its scanned phones in. */
136
+ async follow(joining) {
137
+ this.bringing = true;
138
+ DeviceAccount.keepJoining({ hosts: joining.hosts, devices: joining.devices });
139
+ try {
140
+ if (DeviceAccount.follows(await this.hosts.account.getAccount()) && !this.agent) {
141
+ await this.joinThrough();
142
+ }
143
+ }
144
+ catch (_a) {
145
+ // A ta serve of before, a member who may not, or the account not reached: signed out still, as asked.
146
+ }
147
+ finally {
148
+ this.bringing = false;
149
+ }
150
+ }
115
151
  /** The computers this device brought in, let in as soon as they ask. */
116
152
  async letInBrought(view) {
117
153
  const joining = DeviceAccount.joining();
@@ -82,9 +82,9 @@ const read_aloud_1 = require("./read-aloud");
82
82
  const SLEEP_AFTER_MS = 120000;
83
83
  const CELEBRATE_MS = 4000;
84
84
  const SUGGESTIONS = [
85
- { picture: 'summary', label: 'ta.suggest.1.label', text: 'ta.suggest.1' },
86
- { picture: 'tests', label: 'ta.suggest.2.label', text: 'ta.suggest.2' },
87
- { picture: 'changes', label: 'ta.suggest.3.label', text: 'ta.suggest.3' },
85
+ { picture: 'summary', label: 'ta.suggest.1.label', text: 'ta.suggest.1', project: true },
86
+ { picture: 'tests', label: 'ta.suggest.2.label', text: 'ta.suggest.2', project: true },
87
+ { picture: 'changes', label: 'ta.suggest.3.label', text: 'ta.suggest.3', project: true },
88
88
  ];
89
89
  /** How the double works, in place of a sentence: say it, it runs in the background, it tells you. */
90
90
  const STEPS = [
@@ -120,8 +120,8 @@ const saidByUser = (message, index, messages) => {
120
120
  return (0, earlier_messages_1.isAsk)(message, index, messages) && !assistant_task_util_1.AssistantTaskUtil.noteOf(text);
121
121
  };
122
122
  function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
123
- var _a, _b;
124
- var _c;
123
+ var _a, _b, _c;
124
+ var _d;
125
125
  const t = (0, use_t_1.useT)();
126
126
  const [{ lastFinished, asks }, assistant] = (0, assistant_hooks_1.useAssistant)();
127
127
  const allTasks = (0, hooks_1.useTasks)();
@@ -232,7 +232,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
232
232
  const contextAct = (0, context_act_1.useContextAct)(store);
233
233
  const session = (0, session_settings_1.useSessionSettings)(bench.server, bench.settings, store, state, t, fail, contextAct);
234
234
  // Its own directory, which its tools work in; its tasks open in the default one.
235
- const cwd = (_c = (_a = workbench.sessions.find(open => open.sessionId === store.sessionId)) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _c !== void 0 ? _c : (_b = workbench.server) === null || _b === void 0 ? void 0 : _b.cwd;
235
+ const cwd = (_d = (_a = workbench.sessions.find(open => open.sessionId === store.sessionId)) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _d !== void 0 ? _d : (_b = workbench.server) === null || _b === void 0 ? void 0 : _b.cwd;
236
236
  const messageActions = (0, message_actions_1.useMessageActions)(store, bench.server, state.working, cwd, box, () => undefined);
237
237
  const images = React.useCallback((timestamp, index) => bench.server.getMessageImage(store.sessionId, timestamp, index), [bench.server, store]);
238
238
  const hush = () => {
@@ -347,7 +347,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
347
347
  React.createElement(ta_avatar_1.TaAvatar, { mood: mood, size: 112, className: "ta-hero-avatar", roam: true }),
348
348
  React.createElement("h1", null, t('ta.assistant.hello')),
349
349
  React.createElement(hero_cards_1.HeroSteps, { steps: STEPS }),
350
- React.createElement(hero_cards_1.HeroCards, { suggestions: SUGGESTIONS, onPick: send }))) : (React.createElement(context_line_1.ContextActions.Provider, { value: contextAct },
350
+ React.createElement(hero_cards_1.HeroCards, { suggestions: SUGGESTIONS, starters: addons.starters, project: hero_cards_1.HeroCardsUtil.project(cwd, (_c = workbench.server) === null || _c === void 0 ? void 0 : _c.home), onPick: send }))) : (React.createElement(context_line_1.ContextActions.Provider, { value: contextAct },
351
351
  React.createElement(message_footer_1.MessageActions.Provider, { value: messageActions },
352
352
  React.createElement(message_images_1.MessageImages.Provider, { value: images },
353
353
  React.createElement(assistant_thread_1.AssistantThread, { state: state, reply: answerCard, tasks: allTasks, origin: assistant.sessionFile, rows: rows, onTask: openTask, t: t }))))))),
@@ -1,5 +1,5 @@
1
1
  import type { ClientTool, SessionState, SessionStore } from '@celljs/ta-client';
2
- import { type TaSessionInfo } from '@celljs/ta-protocol';
2
+ import { type TaClientToolDefinition, type TaSessionInfo } from '@celljs/ta-protocol';
3
3
  import { AssistantAskBook } from './assistant-ask-book';
4
4
  import { AssistantConversation } from './assistant-conversation';
5
5
  import { type AssistantAsk, type AssistantTask, TaAssistant } from './assistant-protocol';
@@ -89,6 +89,8 @@ export declare class TaAssistantImpl extends AssistantConversation implements Ta
89
89
  cwd: string;
90
90
  worktree: NonNullable<AssistantTask['worktree']>;
91
91
  }>;
92
+ /** A task works as a chat of the page does: with the web tools of now, whether pi's model or an agent works it. */
93
+ protected webTools(): TaClientToolDefinition[];
92
94
  /**
93
95
  * Watches a task's session: the task runs again when it works (the user or the double said something
94
96
  * to it), and ends when its run did. Gone from the service (it restarted), it is not followed any more:
@@ -10,6 +10,7 @@ exports.TaAssistantImpl = void 0;
10
10
  const core_1 = require("@celljs/core");
11
11
  const ta_protocol_1 = require("@celljs/ta-protocol");
12
12
  const chat_protocol_1 = require("../chat/chat-protocol");
13
+ const web_client_tools_1 = require("../chat/web-client-tools");
13
14
  const chat_asks_1 = require("../components/chat-asks");
14
15
  const chat_busy_1 = require("../components/chat-busy");
15
16
  const chat_icon_1 = require("../components/chat-icon");
@@ -88,7 +89,7 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
88
89
  if (!task.sessionFile) {
89
90
  throw new Error(`No conversation of task ${taskId} is kept.`);
90
91
  }
91
- sessionId = (await this.server.openSession({ cwd: task.cwd, sessionFile: task.sessionFile })).sessionId;
92
+ sessionId = (await this.server.openSession({ cwd: task.cwd, sessionFile: task.sessionFile, clientTools: this.webTools() })).sessionId;
92
93
  }
93
94
  if (sessionId !== task.sessionId) {
94
95
  this.book.change(task, { sessionId });
@@ -181,7 +182,7 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
181
182
  const task = this.book.get(taskId);
182
183
  await ((_a = this.unfollow(taskId)) === null || _a === void 0 ? void 0 : _a.detach().catch(() => undefined));
183
184
  const open = (await this.server.listSessions()).find(session => session.sessionId === task.sessionId || session.sessionFile === task.sessionFile);
184
- const sessionId = (_b = open === null || open === void 0 ? void 0 : open.sessionId) !== null && _b !== void 0 ? _b : (await this.server.openSession({ cwd: task.cwd, sessionFile: task.sessionFile })).sessionId;
185
+ const sessionId = (_b = open === null || open === void 0 ? void 0 : open.sessionId) !== null && _b !== void 0 ? _b : (await this.server.openSession({ cwd: task.cwd, sessionFile: task.sessionFile, clientTools: this.webTools() })).sessionId;
185
186
  this.book.change(task, {
186
187
  sessionId,
187
188
  takenOver: true,
@@ -368,7 +369,7 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
368
369
  }
369
370
  const id = this.book.nextId();
370
371
  const worktree = isolate ? await this.makeWorktree(where, id, title) : undefined;
371
- const info = await this.server.openSession({ cwd: (_d = worktree === null || worktree === void 0 ? void 0 : worktree.cwd) !== null && _d !== void 0 ? _d : where });
372
+ const info = await this.server.openSession({ cwd: (_d = worktree === null || worktree === void 0 ? void 0 : worktree.cwd) !== null && _d !== void 0 ? _d : where, clientTools: this.webTools() });
372
373
  await this.server.setSessionName(info.sessionId, title);
373
374
  await this.setModel(info.sessionId, this.settings.state.settings.taskModel).catch(error => {
374
375
  throw new Error(`The model of the tasks (${this.settings.state.settings.taskModel}) cannot be used: ${error instanceof Error ? error.message : String(error)}`);
@@ -413,13 +414,18 @@ let TaAssistantImpl = class TaAssistantImpl extends assistant_conversation_1.Ass
413
414
  const inside = where.startsWith(`${root}/`) ? where.slice(root.length) : '';
414
415
  return { cwd: `${path}${inside}`, worktree: { path, branch, base } };
415
416
  }
417
+ /** A task works as a chat of the page does: with the web tools of now, whether pi's model or an agent works it. */
418
+ webTools() {
419
+ return web_client_tools_1.WebClientTools.definitions(this.extensions);
420
+ }
416
421
  /**
417
422
  * Watches a task's session: the task runs again when it works (the user or the double said something
418
423
  * to it), and ends when its run did. Gone from the service (it restarted), it is not followed any more:
419
424
  * shown again, it opens from its file; still running, it ended unseen (followRunning).
420
425
  */
421
426
  async follow(task) {
422
- const store = this.workbench.createStore(task.sessionId);
427
+ // It runs the web tools the task has while nobody looks at it (WebClientTools).
428
+ const store = this.workbench.createStore(task.sessionId, { clientTools: web_client_tools_1.WebClientTools.runners(this.extensions) });
423
429
  this.taskStores.set(task.id, store);
424
430
  const stop = store.subscribe(state => this.observe(task.id, state));
425
431
  const stopGone = store.onGone(() => {
@@ -1,4 +1,4 @@
1
- import type { ClientTool, SessionSnapshot, SessionStore } from '@celljs/ta-client';
1
+ import type { SessionSnapshot, SessionStore } from '@celljs/ta-client';
2
2
  import type { TaOpenedSession, TaOpenSessionOptions, TaSessionInfo } from '@celljs/ta-protocol';
3
3
  import type { TaWebExtensions } from '../extension/web-extension-protocol';
4
4
  import type { TaKeptChats } from '../offline/kept-chats-protocol';
@@ -57,7 +57,5 @@ export declare class ChatStores {
57
57
  setDetached(store: SessionStore): boolean;
58
58
  /** Whether `store`, not attached, shows the conversation of `sessionFile`. */
59
59
  standsFor(store: SessionStore, sessionFile: string | undefined): boolean;
60
- /** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
61
- protected clientTool(name: string): ClientTool;
62
60
  }
63
61
  //# sourceMappingURL=chat-stores.d.ts.map
@@ -4,6 +4,7 @@ exports.ChatStores = void 0;
4
4
  const workbench_util_1 = require("../workbench-util");
5
5
  const chat_util_1 = require("./chat-util");
6
6
  const recent_stores_1 = require("./recent-stores");
7
+ const web_client_tools_1 = require("./web-client-tools");
7
8
  /**
8
9
  * The sessions and stores of the conversations TaChat shows. Sessions open, and stores are made, with the
9
10
  * web tools of now (each kept with their names, to tell when they changed); a store starts
@@ -39,7 +40,7 @@ class ChatStores {
39
40
  const opened = await this.workbench.server.openSession({
40
41
  ...options,
41
42
  cwd: ((_a = options.cwd) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = this.workbench.state.server) === null || _b === void 0 ? void 0 : _b.cwd) || '.',
42
- clientTools: tools.map(({ name, description, parameters }) => ({ name, description, parameters })),
43
+ clientTools: web_client_tools_1.WebClientTools.definitions(this.extensions),
43
44
  attach: { recentBytes: workbench_util_1.PAGE_BYTES },
44
45
  });
45
46
  this.opened.set(opened.sessionId, chat_util_1.ChatUtil.toolNames(tools));
@@ -58,7 +59,7 @@ class ChatStores {
58
59
  }
59
60
  /** A store of the session with the web tools of now, showing `initial` until it attaches. */
60
61
  create(sessionId, initial) {
61
- const store = this.workbench.createStore(sessionId, { clientTools: this.extensions.state.tools.map(tool => this.clientTool(tool.name)), initial });
62
+ const store = this.workbench.createStore(sessionId, { clientTools: web_client_tools_1.WebClientTools.runners(this.extensions), initial });
62
63
  this.tools.set(store, this.toolNames());
63
64
  return store;
64
65
  }
@@ -112,22 +113,6 @@ class ChatStores {
112
113
  standsFor(store, sessionFile) {
113
114
  return !!sessionFile && !this.attached.has(store) && this.files.get(store) === sessionFile;
114
115
  }
115
- /** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
116
- clientTool(name) {
117
- var _a;
118
- const tool = () => this.extensions.state.tools.find(candidate => candidate.name === name);
119
- const { description = '', parameters = {} } = (_a = tool()) !== null && _a !== void 0 ? _a : {};
120
- return {
121
- definition: { name, description, parameters },
122
- run: async (input, request) => {
123
- const current = tool();
124
- if (!current) {
125
- throw new Error(`The web extension of the tool ${name} is no longer loaded.`);
126
- }
127
- return current.execute(request.id, (input !== null && input !== void 0 ? input : {}));
128
- },
129
- };
130
- }
131
116
  }
132
117
  exports.ChatStores = ChatStores;
133
118
  //# sourceMappingURL=chat-stores.js.map
@@ -42,6 +42,7 @@ const lucide_react_1 = require("lucide-react");
42
42
  const React = __importStar(require("react"));
43
43
  const callout_1 = require("../components/callout");
44
44
  const composer_1 = require("../components/composer");
45
+ const composer_addons_1 = require("../components/composer-addons");
45
46
  const connection_bar_1 = require("../components/connection-bar");
46
47
  const directory_commands_1 = require("../components/directory-commands");
47
48
  const folder_picker_1 = require("../components/folder-picker");
@@ -79,11 +80,16 @@ function Widget({ widget }) {
79
80
  }
80
81
  function Hero({ cwd, onPick }) {
81
82
  const t = (0, use_t_1.useT)();
83
+ const [{ server }] = (0, hooks_1.useWorkbench)();
84
+ const project = hero_cards_1.HeroCardsUtil.project(cwd, server === null || server === void 0 ? void 0 : server.home);
85
+ // What packages offer to start with (WebComposerAddon.starters): those of any conversation, the session not yet there.
86
+ const conversation = React.useMemo(() => ({ sessionId: '', cwd, kind: 'chat' }), [cwd]);
87
+ const { starters } = (0, composer_addons_1.useComposerAddons)(conversation);
82
88
  return (React.createElement("div", { className: "ta-hero" },
83
89
  React.createElement(ta_avatar_1.TaAvatar, { size: 88, className: "ta-hero-face", roam: true }),
84
90
  React.createElement("h1", null, t('ta.chat.title')),
85
- React.createElement("p", null, t('ta.chat.hint', { cwd: message_1.MessageUtil.basename(cwd) || cwd })),
86
- React.createElement(hero_cards_1.HeroCards, { suggestions: SUGGESTIONS, onPick: onPick })));
91
+ React.createElement("p", null, project ? t('ta.chat.hint', { cwd: message_1.MessageUtil.basename(cwd) || cwd }) : t('ta.chat.hintHome')),
92
+ React.createElement(hero_cards_1.HeroCards, { suggestions: SUGGESTIONS, starters: starters, project: project, onPick: onPick })));
87
93
  }
88
94
  /** A new conversation: the message box opens it, in the directory shown above it, which may be changed. */
89
95
  function DraftView({ draft, menu, aboveComposer, belowComposer }) {
@@ -0,0 +1,16 @@
1
+ import type { ClientTool } from '@celljs/ta-client';
2
+ import type { TaClientToolDefinition } from '@celljs/ta-protocol';
3
+ import type { TaWebExtensions } from '../extension/web-extension-protocol';
4
+ /**
5
+ * The web tools of now as tools of a session (`clientTools`): what a session opens with, and what a store of
6
+ * it runs. Every session the page opens for the user's work has them, a chat or a task the double starts, so
7
+ * that whoever works in it (pi's model, or an agent through MCP) can work the page as the user can: the
8
+ * browser of the workbench, say.
9
+ */
10
+ export declare namespace WebClientTools {
11
+ function definitions(extensions: TaWebExtensions): TaClientToolDefinition[];
12
+ /** What a store runs: each tool as it is loaded when the model calls it, a changed one as it is now. */
13
+ function runners(extensions: TaWebExtensions): ClientTool[];
14
+ function runner(extensions: TaWebExtensions, name: string): ClientTool;
15
+ }
16
+ //# sourceMappingURL=web-client-tools.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebClientTools = void 0;
4
+ /**
5
+ * The web tools of now as tools of a session (`clientTools`): what a session opens with, and what a store of
6
+ * it runs. Every session the page opens for the user's work has them, a chat or a task the double starts, so
7
+ * that whoever works in it (pi's model, or an agent through MCP) can work the page as the user can: the
8
+ * browser of the workbench, say.
9
+ */
10
+ var WebClientTools;
11
+ (function (WebClientTools) {
12
+ function definitions(extensions) {
13
+ return extensions.state.tools.map(({ name, description, parameters }) => ({ name, description, parameters }));
14
+ }
15
+ WebClientTools.definitions = definitions;
16
+ /** What a store runs: each tool as it is loaded when the model calls it, a changed one as it is now. */
17
+ function runners(extensions) {
18
+ return extensions.state.tools.map(tool => runner(extensions, tool.name));
19
+ }
20
+ WebClientTools.runners = runners;
21
+ function runner(extensions, name) {
22
+ var _a;
23
+ const tool = () => extensions.state.tools.find(candidate => candidate.name === name);
24
+ const { description = '', parameters = {} } = (_a = tool()) !== null && _a !== void 0 ? _a : {};
25
+ return {
26
+ definition: { name, description, parameters },
27
+ run: async (input, request) => {
28
+ const current = tool();
29
+ if (!current) {
30
+ throw new Error(`The web extension of the tool ${name} is no longer loaded.`);
31
+ }
32
+ return current.execute(request.id, (input !== null && input !== void 0 ? input : {}));
33
+ },
34
+ };
35
+ }
36
+ WebClientTools.runner = runner;
37
+ })(WebClientTools || (exports.WebClientTools = WebClientTools = {}));
38
+ //# sourceMappingURL=web-client-tools.js.map
@@ -100,9 +100,12 @@ function SignInPart({ info, act }) {
100
100
  const [, notices] = (0, hooks_1.useNotices)();
101
101
  const go = (action) => void run(() => act(action).catch((error) => notices.error(error)));
102
102
  // The web-view of the mini program opens no page of another domain: the page of the provider is copied, for a browser.
103
- const openProvider = (url) => {
103
+ // The code is copied as the provider's page opens, to be pasted there; a tap on it copies it again.
104
+ const copyCode = (code, provider) => { var _a; return void ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(code).then(() => notices.notify(t('ta.myDevices.codeCopied', { name: providerName(info, provider) }), { level: 'success' })).catch(() => undefined)); };
105
+ const openProvider = (url, code) => {
104
106
  var _a;
105
107
  if (!mini_program_1.MiniProgram.inside()) {
108
+ copyCode(code.code, code.provider);
106
109
  window.open(url, '_blank', 'noopener,noreferrer');
107
110
  return;
108
111
  }
@@ -113,8 +116,8 @@ function SignInPart({ info, act }) {
113
116
  const name = providerName(info, signing.provider);
114
117
  return (React.createElement("div", { className: "ta-account-signing" },
115
118
  React.createElement("p", null, t('ta.myDevices.enterCode', { name })),
116
- React.createElement(cloud_sign_in_view_1.CodeBox, { code: signing.code }),
117
- React.createElement("button", { type: "button", className: "ta-button ta-primary ta-wide", onClick: () => openProvider(signing.url) },
119
+ React.createElement(cloud_sign_in_view_1.CodeBox, { code: signing.code, onCopy: () => copyCode(signing.code, signing.provider) }),
120
+ React.createElement("button", { type: "button", className: "ta-button ta-primary ta-wide", onClick: () => openProvider(signing.url, signing) },
118
121
  React.createElement(sign_in_marks_1.SignInMark, { provider: signing.provider, size: 16 }),
119
122
  " ",
120
123
  t('ta.myDevices.openProvider', { name })),
@@ -127,7 +130,7 @@ function SignInPart({ info, act }) {
127
130
  return (React.createElement("div", { className: "ta-account-ways" }, ways.map(provider => (React.createElement("button", { key: `${provider.service} ${provider.id}`, type: "button", className: busy ? 'ta-button ta-primary ta-wide ta-busy' : 'ta-button ta-primary ta-wide', "aria-busy": busy || undefined, onClick: () => go(async (side) => {
128
131
  const next = await side.signIn(provider.id, provider.service);
129
132
  if (next.signingIn) {
130
- openProvider(next.signingIn.url);
133
+ openProvider(next.signingIn.url, next.signingIn);
131
134
  }
132
135
  return next;
133
136
  }) },
@@ -73,7 +73,8 @@ exports.EDITOR = { key: 'editor', initial: 480, min: 320, max: 1200 };
73
73
  /** The width of the navigation rail, in style.ts. */
74
74
  exports.RAIL = 56;
75
75
  /** Whether the workbench on the right shows, in this browser, whose screen decides. */
76
- const RIGHT = { key: 'panel', tier: 'device', initial: true, parse: state_protocol_1.StateUtil.boolean };
76
+ /** Closed at first: a new user meets the conversation alone; a tab opened, or the toggle, shows it (docs/design/ta-onboarding.md). */
77
+ const RIGHT = { key: 'panel', tier: 'device', initial: false, parse: state_protocol_1.StateUtil.boolean };
77
78
  /** Sessions change with other clients too; while the tab is visible they are read again now and then. */
78
79
  const REFRESH_MS = 5000;
79
80
  /** As often, where the server tells the open sessions as they change (sessionsPushed): what is left to read is the saved ones and the directory. */