@celljs/ta-web 4.9.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +5 -4
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +26 -8
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/web-extension-api.d.ts +97 -1
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +122 -23
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +27 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +46 -3
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +5 -4
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +26 -8
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/web-extension-api.d.ts +97 -1
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +120 -21
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +27 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +46 -3
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -11,7 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TaAssistantImpl = void 0;
|
|
13
13
|
const core_1 = require("@celljs/core");
|
|
14
|
+
const ta_client_1 = require("@celljs/ta-client");
|
|
14
15
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
16
|
+
const kept_chats_protocol_1 = require("../offline/kept-chats-protocol");
|
|
15
17
|
const settings_protocol_1 = require("../settings/settings-protocol");
|
|
16
18
|
const state_protocol_1 = require("../state/state-protocol");
|
|
17
19
|
const workbench_protocol_1 = require("../workbench-protocol");
|
|
@@ -62,6 +64,11 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
62
64
|
(_a = this.unwatchSettings) !== null && _a !== void 0 ? _a : (this.unwatchSettings = this.settings.subscribe(state => this.settingsChanged(state.settings)));
|
|
63
65
|
(_b = this.starting) !== null && _b !== void 0 ? _b : (this.starting = this.open().catch(error => {
|
|
64
66
|
this.starting = undefined;
|
|
67
|
+
if (ta_client_1.TaRemoteError.isConnectionLost(error)) {
|
|
68
|
+
// No failure to show: it wakes once the connection is back (a moment after, not in a loop).
|
|
69
|
+
setTimeout(() => void this.workbench.connected().then(() => (this.starting || this.assistant ? undefined : this.start()), () => undefined), 1000);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
65
72
|
this.update({ error: error instanceof Error ? error.message : String(error) });
|
|
66
73
|
}));
|
|
67
74
|
return this.starting;
|
|
@@ -72,7 +79,17 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
store() {
|
|
75
|
-
|
|
82
|
+
var _a;
|
|
83
|
+
return (_a = this.assistant) !== null && _a !== void 0 ? _a : this.preview;
|
|
84
|
+
}
|
|
85
|
+
async showKept() {
|
|
86
|
+
const file = this.assistant || this.preview ? undefined : await this.persisted.load(FILE);
|
|
87
|
+
const initial = file ? await this.kept.read(file).catch(() => undefined) : undefined;
|
|
88
|
+
if (initial && !this.assistant && !this.preview) {
|
|
89
|
+
// Under its file: it is of no session until the conversation opens, which takes over what it shows.
|
|
90
|
+
this.preview = this.workbench.createStore(file, { initial });
|
|
91
|
+
this.update({});
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
async loadTasks() {
|
|
78
95
|
this.watchTasks();
|
|
@@ -154,6 +171,9 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
154
171
|
// Opening (again, after a reconnect found it gone): sent once it is open.
|
|
155
172
|
await this.starting;
|
|
156
173
|
const store = this.assistant;
|
|
174
|
+
if (!store && this.workbench.state.status !== 'online') {
|
|
175
|
+
throw ta_client_1.TaRemoteError.notConnected();
|
|
176
|
+
}
|
|
157
177
|
if (!store) {
|
|
158
178
|
throw new Error('Ta is not ready yet.');
|
|
159
179
|
}
|
|
@@ -305,6 +325,18 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
305
325
|
this.persisted.set(FILE, sessionFile);
|
|
306
326
|
}
|
|
307
327
|
}
|
|
328
|
+
/** Keeps the conversation on the device as it changes, under its file of the time (`restart` gives it another). */
|
|
329
|
+
keep(store) {
|
|
330
|
+
var _a;
|
|
331
|
+
(_a = this.unkeep) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
332
|
+
let file = this.sessionFile;
|
|
333
|
+
this.unkeep = this.kept.follow(store, () => {
|
|
334
|
+
if (this.assistant === store) {
|
|
335
|
+
file = this.sessionFile;
|
|
336
|
+
}
|
|
337
|
+
return file;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
308
340
|
/** The role of ta, whether it asks first, and what the user added to it. */
|
|
309
341
|
systemPrompt() {
|
|
310
342
|
return (0, assistant_role_1.assistantRole)(this.settings.state.settings.confirmTasks, this.prompt);
|
|
@@ -337,8 +369,8 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
337
369
|
* trip to ta serve, which over a relay or a phone's network takes long.
|
|
338
370
|
*/
|
|
339
371
|
async open() {
|
|
340
|
-
var _a;
|
|
341
|
-
var
|
|
372
|
+
var _a, _b;
|
|
373
|
+
var _c;
|
|
342
374
|
this.watchTasks();
|
|
343
375
|
const clientTools = this.clientTools();
|
|
344
376
|
const [tasks, file, wasAsking, sessions] = await Promise.all([
|
|
@@ -363,7 +395,7 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
363
395
|
if (!info) {
|
|
364
396
|
this.persisted.set(ASKING, asking);
|
|
365
397
|
const options = {
|
|
366
|
-
cwd: (
|
|
398
|
+
cwd: (_c = (_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _c !== void 0 ? _c : '.',
|
|
367
399
|
appendSystemPrompt: this.systemPrompt(),
|
|
368
400
|
clientTools: clientTools.map(tool => tool.definition),
|
|
369
401
|
};
|
|
@@ -381,7 +413,8 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
381
413
|
}
|
|
382
414
|
const { sessionId } = info;
|
|
383
415
|
this.cwd = info.cwd;
|
|
384
|
-
|
|
416
|
+
// What the device kept shows on: the messages that are the same keep their objects.
|
|
417
|
+
const store = this.workbench.createStore(sessionId, { clientTools, initial: (_b = this.preview) === null || _b === void 0 ? void 0 : _b.state });
|
|
385
418
|
await Promise.all([named ? this.server.setSessionName(sessionId, 'Ta') : undefined, this.applyModel(sessionId, info.model), store.attach()]);
|
|
386
419
|
store.onGone(() => void this.recover(store));
|
|
387
420
|
store.subscribe(state => {
|
|
@@ -390,6 +423,8 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
390
423
|
}
|
|
391
424
|
});
|
|
392
425
|
this.assistant = store;
|
|
426
|
+
this.preview = undefined;
|
|
427
|
+
this.keep(store);
|
|
393
428
|
this.update({ ready: true, error: undefined });
|
|
394
429
|
this.flushNotes();
|
|
395
430
|
await this.followRunning(sessions);
|
|
@@ -601,6 +636,10 @@ __decorate([
|
|
|
601
636
|
(0, core_1.Autowired)(settings_protocol_1.TaSettings),
|
|
602
637
|
__metadata("design:type", Object)
|
|
603
638
|
], TaAssistantImpl.prototype, "settings", void 0);
|
|
639
|
+
__decorate([
|
|
640
|
+
(0, core_1.Autowired)(kept_chats_protocol_1.TaKeptChats),
|
|
641
|
+
__metadata("design:type", Object)
|
|
642
|
+
], TaAssistantImpl.prototype, "kept", void 0);
|
|
604
643
|
exports.TaAssistantImpl = TaAssistantImpl = __decorate([
|
|
605
644
|
(0, core_1.Component)(assistant_protocol_1.TaAssistant)
|
|
606
645
|
], TaAssistantImpl);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SessionStore } from '@celljs/ta-client';
|
|
2
|
+
import type { TaWebExtensions } from '../extension/web-extension-protocol';
|
|
3
|
+
import type { TaWorkbench } from '../workbench-protocol';
|
|
4
|
+
import type { ChatStores } from './chat-stores';
|
|
5
|
+
/** What ChatPackages needs of the conversation shown (TaChat). */
|
|
6
|
+
export interface PackagesHost {
|
|
7
|
+
shown(): SessionStore | undefined;
|
|
8
|
+
/** One change of the conversation shown at a time. */
|
|
9
|
+
enqueue(change: () => Promise<void>): Promise<void>;
|
|
10
|
+
/** The same conversation, from its file, with the tools of now. */
|
|
11
|
+
reopen(store: SessionStore): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The packages of the conversation shown, after a run in which ta may have made or changed one: the web
|
|
15
|
+
* extensions load again; new or removed web tools open the conversation again with them; a changed package
|
|
16
|
+
* has its pi extensions loaded again. A new run in the meantime puts both off to its end.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ChatPackages {
|
|
19
|
+
protected readonly extensions: TaWebExtensions;
|
|
20
|
+
protected readonly workbench: TaWorkbench;
|
|
21
|
+
protected readonly stores: ChatStores;
|
|
22
|
+
protected readonly host: PackagesHost;
|
|
23
|
+
/** The runs of tools of the conversation shown, seen before: only those after are its edits. */
|
|
24
|
+
protected readonly seen: Set<string>;
|
|
25
|
+
/** A web extension changed packages during a run: its end loads them again. */
|
|
26
|
+
protected pending: boolean;
|
|
27
|
+
constructor(extensions: TaWebExtensions, workbench: TaWorkbench, stores: ChatStores, host: PackagesHost);
|
|
28
|
+
/** The runs of a store so far are not edits of a run to come; `fresh`: a store shown in place of another. */
|
|
29
|
+
saw(store: SessionStore, fresh?: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* A run ended, in which ta may have made or changed a package. The web extensions load again. New or
|
|
32
|
+
* removed web tools need the conversation opened again with them; a changed package needs its pi
|
|
33
|
+
* extensions loaded again. A new run in the meantime puts both off to its end.
|
|
34
|
+
*/
|
|
35
|
+
settled(store: SessionStore): Promise<void>;
|
|
36
|
+
/** A web extension changed packages (reloadExtensions): as at the end of a run, or at the end of the one under way. */
|
|
37
|
+
reload(store: SessionStore): Promise<void>;
|
|
38
|
+
protected load(store: SessionStore, changed: boolean): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=chat-packages.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatPackages = void 0;
|
|
4
|
+
const chat_util_1 = require("./chat-util");
|
|
5
|
+
/**
|
|
6
|
+
* The packages of the conversation shown, after a run in which ta may have made or changed one: the web
|
|
7
|
+
* extensions load again; new or removed web tools open the conversation again with them; a changed package
|
|
8
|
+
* has its pi extensions loaded again. A new run in the meantime puts both off to its end.
|
|
9
|
+
*/
|
|
10
|
+
class ChatPackages {
|
|
11
|
+
constructor(extensions, workbench, stores, host) {
|
|
12
|
+
this.extensions = extensions;
|
|
13
|
+
this.workbench = workbench;
|
|
14
|
+
this.stores = stores;
|
|
15
|
+
this.host = host;
|
|
16
|
+
/** The runs of tools of the conversation shown, seen before: only those after are its edits. */
|
|
17
|
+
this.seen = new Set();
|
|
18
|
+
/** A web extension changed packages during a run: its end loads them again. */
|
|
19
|
+
this.pending = false;
|
|
20
|
+
}
|
|
21
|
+
/** The runs of a store so far are not edits of a run to come; `fresh`: a store shown in place of another. */
|
|
22
|
+
saw(store, fresh = false) {
|
|
23
|
+
if (fresh) {
|
|
24
|
+
this.seen.clear();
|
|
25
|
+
}
|
|
26
|
+
for (const id of Object.keys(store.state.tools)) {
|
|
27
|
+
this.seen.add(id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A run ended, in which ta may have made or changed a package. The web extensions load again. New or
|
|
32
|
+
* removed web tools need the conversation opened again with them; a changed package needs its pi
|
|
33
|
+
* extensions loaded again. A new run in the meantime puts both off to its end.
|
|
34
|
+
*/
|
|
35
|
+
settled(store) {
|
|
36
|
+
return this.host.enqueue(chat_util_1.ChatUtil.quietly(async () => {
|
|
37
|
+
const changed = await this.extensions.refresh();
|
|
38
|
+
const edits = chat_util_1.ChatUtil.packageEdits(store.state, this.seen);
|
|
39
|
+
for (const id of edits) {
|
|
40
|
+
this.seen.add(id);
|
|
41
|
+
}
|
|
42
|
+
if (store !== this.host.shown() || store.state.working) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const pending = this.pending;
|
|
46
|
+
this.pending = false;
|
|
47
|
+
await this.load(store, changed || edits.length > 0 || pending);
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/** A web extension changed packages (reloadExtensions): as at the end of a run, or at the end of the one under way. */
|
|
51
|
+
reload(store) {
|
|
52
|
+
return this.host.enqueue(async () => {
|
|
53
|
+
if (store !== this.host.shown()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (store.state.working) {
|
|
57
|
+
this.pending = true;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
await this.load(store, true);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async load(store, changed) {
|
|
64
|
+
const tools = this.stores.openedWith(store.sessionId);
|
|
65
|
+
if (tools !== undefined && tools !== this.stores.toolNames()) {
|
|
66
|
+
await this.host.reopen(store);
|
|
67
|
+
}
|
|
68
|
+
else if (changed) {
|
|
69
|
+
await this.workbench.server.reload(store.sessionId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ChatPackages = ChatPackages;
|
|
74
|
+
//# sourceMappingURL=chat-packages.js.map
|
|
@@ -10,11 +10,23 @@ export interface ChatDraft {
|
|
|
10
10
|
cwd: string;
|
|
11
11
|
/** `<provider>/<model id>` it will start on; none: the default model of the settings. */
|
|
12
12
|
model?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Its first message, shown at once while its session opens, or `failed` to open it. `heldAt`: when the
|
|
15
|
+
* connection was lost opening it; it opens once the connection is back, and fails only after HOLD_MS.
|
|
16
|
+
*/
|
|
17
|
+
sending?: {
|
|
18
|
+
message: string;
|
|
19
|
+
images?: ImageContent[];
|
|
20
|
+
failed?: string;
|
|
21
|
+
heldAt?: number;
|
|
22
|
+
};
|
|
13
23
|
}
|
|
14
24
|
/** What a conversation still opening says of itself, before the server has it (TaChat.show of a session on its way). */
|
|
15
25
|
export interface ChatOpening {
|
|
16
26
|
title?: string;
|
|
17
27
|
cwd?: string;
|
|
28
|
+
/** Its file, when known: what this device kept of it shows while it opens, without the computer too. */
|
|
29
|
+
sessionFile?: string;
|
|
18
30
|
}
|
|
19
31
|
export interface ChatState {
|
|
20
32
|
/** The conversation shown, once there is one. */
|
|
@@ -49,8 +61,18 @@ export interface TaChat {
|
|
|
49
61
|
setDraftCwd(cwd: string): Promise<void>;
|
|
50
62
|
/** The model the new conversation starts on; none: the default one. */
|
|
51
63
|
setDraftModel(model: string | undefined): void;
|
|
52
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Opens the session of the new conversation and sends its first message. When that fails the message
|
|
66
|
+
* stays, marked failed (`ChatDraft.sending`), to send again or take back. Another message while it
|
|
67
|
+
* opens follows the first.
|
|
68
|
+
*/
|
|
53
69
|
submit(message: string, images?: ImageContent[]): Promise<void>;
|
|
70
|
+
/** Sends again the first message that failed. */
|
|
71
|
+
resendDraft(): Promise<void>;
|
|
72
|
+
/** Takes back the first message that failed. */
|
|
73
|
+
discardDraft(): void;
|
|
74
|
+
/** Stops the run of the conversation still opening, once it is there. */
|
|
75
|
+
stopDraft(): void;
|
|
54
76
|
/**
|
|
55
77
|
* Shows an open session; one the service closed meanwhile opens again from its file. A session still on its
|
|
56
78
|
* way (a promise of its id) has its place at once, said by `opening`, and shows when it comes; it fails as it fails.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ClientTool, SessionSnapshot, SessionStore } from '@celljs/ta-client';
|
|
2
|
+
import type { TaOpenSessionOptions, TaSessionInfo } from '@celljs/ta-protocol';
|
|
3
|
+
import type { TaWebExtensions } from '../extension/web-extension-protocol';
|
|
4
|
+
import type { TaKeptChats } from '../offline/kept-chats-protocol';
|
|
5
|
+
import type { TaWorkbench } from '../workbench-protocol';
|
|
6
|
+
import { RecentStores } from './recent-stores';
|
|
7
|
+
/**
|
|
8
|
+
* The sessions and stores of the conversations TaChat shows. Sessions open, and stores are made, with the
|
|
9
|
+
* web tools of now (each kept with their names, to tell when they changed); a store starts
|
|
10
|
+
* from what the device kept of its conversation when it has it, and knows whether it is attached. One that is
|
|
11
|
+
* not shows a conversation as the device kept it, until the connection is there: it is not kept among the
|
|
12
|
+
* recent ones, the device has it.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ChatStores {
|
|
15
|
+
protected readonly workbench: TaWorkbench;
|
|
16
|
+
protected readonly kept: TaKeptChats;
|
|
17
|
+
protected readonly extensions: TaWebExtensions;
|
|
18
|
+
/** The conversations shown before, to show again at once. */
|
|
19
|
+
readonly recent: RecentStores;
|
|
20
|
+
protected readonly tools: WeakMap<SessionStore, string>;
|
|
21
|
+
/** The tools of the sessions this page opened, by session: only those are opened again when the tools change. */
|
|
22
|
+
protected readonly opened: Map<string, string>;
|
|
23
|
+
protected readonly attached: WeakSet<SessionStore>;
|
|
24
|
+
/** The file of the conversation a store not attached shows: the store that attaches for it takes on what failed to go there. */
|
|
25
|
+
protected readonly files: WeakMap<SessionStore, string>;
|
|
26
|
+
constructor(workbench: TaWorkbench, kept: TaKeptChats, extensions: TaWebExtensions);
|
|
27
|
+
/** The names of the web tools of now. */
|
|
28
|
+
toolNames(): string;
|
|
29
|
+
/** Opens a session with the web tools of now. */
|
|
30
|
+
open(options: Partial<TaOpenSessionOptions>): Promise<string>;
|
|
31
|
+
/** The names of the tools this page opened a session with; none for one it did not open. */
|
|
32
|
+
openedWith(sessionId: string): string | undefined;
|
|
33
|
+
/** The session closed. */
|
|
34
|
+
closed(sessionId: string): void;
|
|
35
|
+
/** A store of the session with the web tools of now, showing `initial` until it attaches. */
|
|
36
|
+
create(sessionId: string, initial?: SessionSnapshot): SessionStore;
|
|
37
|
+
/** A store, not attached, of the conversation of `sessionFile` as the device kept it, under `key`; none if it kept none. */
|
|
38
|
+
fromDevice(key: string, sessionFile: string | undefined): Promise<SessionStore | undefined>;
|
|
39
|
+
/** The conversation under `key` as this page or else this device had it, not attached: one shown lately, else the one of its file (else the list's). */
|
|
40
|
+
shown(key: string, sessionFile: string | undefined): Promise<SessionStore | undefined>;
|
|
41
|
+
/** What the device kept of the conversation of a file. */
|
|
42
|
+
read(sessionFile: string | undefined): Promise<SessionSnapshot | undefined>;
|
|
43
|
+
/** Whether the list has the session open. */
|
|
44
|
+
listed(sessionId: string): boolean;
|
|
45
|
+
/** The open session of a file. */
|
|
46
|
+
openOf(sessionFile: string): TaSessionInfo | undefined;
|
|
47
|
+
/** The file of an open session of the list. */
|
|
48
|
+
fileOf(sessionId: string): string | undefined;
|
|
49
|
+
/** The names of the web tools a store runs. */
|
|
50
|
+
toolsOf(store: SessionStore): string | undefined;
|
|
51
|
+
isAttached(store: SessionStore): boolean;
|
|
52
|
+
setAttached(store: SessionStore): void;
|
|
53
|
+
/** It is detached: whether it was attached. */
|
|
54
|
+
setDetached(store: SessionStore): boolean;
|
|
55
|
+
/** Whether `store`, not attached, shows the conversation of `sessionFile`. */
|
|
56
|
+
standsFor(store: SessionStore, sessionFile: string | undefined): boolean;
|
|
57
|
+
/** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
|
|
58
|
+
protected clientTool(name: string): ClientTool;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=chat-stores.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatStores = void 0;
|
|
4
|
+
const chat_util_1 = require("./chat-util");
|
|
5
|
+
const recent_stores_1 = require("./recent-stores");
|
|
6
|
+
/**
|
|
7
|
+
* The sessions and stores of the conversations TaChat shows. Sessions open, and stores are made, with the
|
|
8
|
+
* web tools of now (each kept with their names, to tell when they changed); a store starts
|
|
9
|
+
* from what the device kept of its conversation when it has it, and knows whether it is attached. One that is
|
|
10
|
+
* not shows a conversation as the device kept it, until the connection is there: it is not kept among the
|
|
11
|
+
* recent ones, the device has it.
|
|
12
|
+
*/
|
|
13
|
+
class ChatStores {
|
|
14
|
+
constructor(workbench, kept, extensions) {
|
|
15
|
+
this.workbench = workbench;
|
|
16
|
+
this.kept = kept;
|
|
17
|
+
this.extensions = extensions;
|
|
18
|
+
/** The conversations shown before, to show again at once. */
|
|
19
|
+
this.recent = new recent_stores_1.RecentStores();
|
|
20
|
+
this.tools = new WeakMap();
|
|
21
|
+
/** The tools of the sessions this page opened, by session: only those are opened again when the tools change. */
|
|
22
|
+
this.opened = new Map();
|
|
23
|
+
this.attached = new WeakSet();
|
|
24
|
+
/** The file of the conversation a store not attached shows: the store that attaches for it takes on what failed to go there. */
|
|
25
|
+
this.files = new WeakMap();
|
|
26
|
+
}
|
|
27
|
+
/** The names of the web tools of now. */
|
|
28
|
+
toolNames() {
|
|
29
|
+
return chat_util_1.ChatUtil.toolNames(this.extensions.state.tools);
|
|
30
|
+
}
|
|
31
|
+
/** Opens a session with the web tools of now. */
|
|
32
|
+
async open(options) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const tools = this.extensions.state.tools;
|
|
35
|
+
const { sessionId } = await this.workbench.server.openSession({
|
|
36
|
+
...options,
|
|
37
|
+
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) || '.',
|
|
38
|
+
clientTools: tools.map(({ name, description, parameters }) => ({ name, description, parameters })),
|
|
39
|
+
});
|
|
40
|
+
this.opened.set(sessionId, chat_util_1.ChatUtil.toolNames(tools));
|
|
41
|
+
return sessionId;
|
|
42
|
+
}
|
|
43
|
+
/** The names of the tools this page opened a session with; none for one it did not open. */
|
|
44
|
+
openedWith(sessionId) {
|
|
45
|
+
return this.opened.get(sessionId);
|
|
46
|
+
}
|
|
47
|
+
/** The session closed. */
|
|
48
|
+
closed(sessionId) {
|
|
49
|
+
this.opened.delete(sessionId);
|
|
50
|
+
}
|
|
51
|
+
/** A store of the session with the web tools of now, showing `initial` until it attaches. */
|
|
52
|
+
create(sessionId, initial) {
|
|
53
|
+
const store = this.workbench.createStore(sessionId, { clientTools: this.extensions.state.tools.map(tool => this.clientTool(tool.name)), initial });
|
|
54
|
+
this.tools.set(store, this.toolNames());
|
|
55
|
+
return store;
|
|
56
|
+
}
|
|
57
|
+
/** A store, not attached, of the conversation of `sessionFile` as the device kept it, under `key`; none if it kept none. */
|
|
58
|
+
async fromDevice(key, sessionFile) {
|
|
59
|
+
const initial = await this.read(sessionFile);
|
|
60
|
+
if (!sessionFile || !initial) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const store = this.create(key, initial);
|
|
64
|
+
this.files.set(store, sessionFile);
|
|
65
|
+
return store;
|
|
66
|
+
}
|
|
67
|
+
/** The conversation under `key` as this page or else this device had it, not attached: one shown lately, else the one of its file (else the list's). */
|
|
68
|
+
async shown(key, sessionFile) {
|
|
69
|
+
var _a;
|
|
70
|
+
return (_a = this.recent.take(key, this.toolNames())) !== null && _a !== void 0 ? _a : (await this.fromDevice(key, sessionFile !== null && sessionFile !== void 0 ? sessionFile : this.fileOf(key)));
|
|
71
|
+
}
|
|
72
|
+
/** What the device kept of the conversation of a file. */
|
|
73
|
+
read(sessionFile) {
|
|
74
|
+
return sessionFile ? this.kept.read(sessionFile).catch(() => undefined) : Promise.resolve(undefined);
|
|
75
|
+
}
|
|
76
|
+
/** Whether the list has the session open. */
|
|
77
|
+
listed(sessionId) {
|
|
78
|
+
return this.workbench.state.sessions.some(session => session.sessionId === sessionId);
|
|
79
|
+
}
|
|
80
|
+
/** The open session of a file. */
|
|
81
|
+
openOf(sessionFile) {
|
|
82
|
+
return this.workbench.state.sessions.find(session => session.sessionFile === sessionFile);
|
|
83
|
+
}
|
|
84
|
+
/** The file of an open session of the list. */
|
|
85
|
+
fileOf(sessionId) {
|
|
86
|
+
var _a;
|
|
87
|
+
return (_a = this.workbench.state.sessions.find(session => session.sessionId === sessionId)) === null || _a === void 0 ? void 0 : _a.sessionFile;
|
|
88
|
+
}
|
|
89
|
+
/** The names of the web tools a store runs. */
|
|
90
|
+
toolsOf(store) {
|
|
91
|
+
return this.tools.get(store);
|
|
92
|
+
}
|
|
93
|
+
isAttached(store) {
|
|
94
|
+
return this.attached.has(store);
|
|
95
|
+
}
|
|
96
|
+
setAttached(store) {
|
|
97
|
+
this.attached.add(store);
|
|
98
|
+
}
|
|
99
|
+
/** It is detached: whether it was attached. */
|
|
100
|
+
setDetached(store) {
|
|
101
|
+
return this.attached.delete(store);
|
|
102
|
+
}
|
|
103
|
+
/** Whether `store`, not attached, shows the conversation of `sessionFile`. */
|
|
104
|
+
standsFor(store, sessionFile) {
|
|
105
|
+
return !!sessionFile && !this.attached.has(store) && this.files.get(store) === sessionFile;
|
|
106
|
+
}
|
|
107
|
+
/** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
|
|
108
|
+
clientTool(name) {
|
|
109
|
+
var _a;
|
|
110
|
+
const tool = () => this.extensions.state.tools.find(candidate => candidate.name === name);
|
|
111
|
+
const { description = '', parameters = {} } = (_a = tool()) !== null && _a !== void 0 ? _a : {};
|
|
112
|
+
return {
|
|
113
|
+
definition: { name, description, parameters },
|
|
114
|
+
run: async (input, request) => {
|
|
115
|
+
const current = tool();
|
|
116
|
+
if (!current) {
|
|
117
|
+
throw new Error(`The web extension of the tool ${name} is no longer loaded.`);
|
|
118
|
+
}
|
|
119
|
+
return current.execute(request.id, (input !== null && input !== void 0 ? input : {}));
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.ChatStores = ChatStores;
|
|
125
|
+
//# sourceMappingURL=chat-stores.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SessionState } from '@celljs/ta-client';
|
|
2
|
+
import type { WebTool } from '../extension/web-extension-api';
|
|
3
|
+
export declare namespace ChatUtil {
|
|
4
|
+
function toolNames(tools: WebTool[]): string;
|
|
5
|
+
/** Ids of the runs of `write` and `edit` in a directory of packages that are not in `seen`. */
|
|
6
|
+
function packageEdits(state: SessionState, seen: Set<string>): string[];
|
|
7
|
+
function message(error: unknown): string;
|
|
8
|
+
/** Only the connection was lost: it mends itself, and what it cut off goes again once it is back. */
|
|
9
|
+
function lost(error: unknown): boolean;
|
|
10
|
+
/** A change nobody asked for now (after a run): a lost connection is no failure to tell, the next run does it again. */
|
|
11
|
+
function quietly(change: () => Promise<void>): () => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Runs `run` again each time the connection is lost under it and comes back, while `wanted` (a few times
|
|
14
|
+
* at most): opening a conversation on a network that drops goes on, rather than failing.
|
|
15
|
+
*/
|
|
16
|
+
function untilConnected(run: () => Promise<void>, connected: () => Promise<void>, wanted: () => boolean): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=chat-util.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatUtil = void 0;
|
|
4
|
+
const ta_client_1 = require("@celljs/ta-client");
|
|
5
|
+
/** A file in a directory of packages: `extensions/<name>/...`, of the user or a project. */
|
|
6
|
+
const PACKAGE_FILE = /(^|[\\/])extensions[\\/][^\\/]+[\\/]/;
|
|
7
|
+
var ChatUtil;
|
|
8
|
+
(function (ChatUtil) {
|
|
9
|
+
function toolNames(tools) {
|
|
10
|
+
return tools
|
|
11
|
+
.map(tool => tool.name)
|
|
12
|
+
.sort()
|
|
13
|
+
.join(',');
|
|
14
|
+
}
|
|
15
|
+
ChatUtil.toolNames = toolNames;
|
|
16
|
+
/** Ids of the runs of `write` and `edit` in a directory of packages that are not in `seen`. */
|
|
17
|
+
function packageEdits(state, seen) {
|
|
18
|
+
return Object.entries(state.tools)
|
|
19
|
+
.filter(([id, run]) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const path = (_a = run.args) === null || _a === void 0 ? void 0 : _a.path;
|
|
22
|
+
return !seen.has(id) && (run.toolName === 'write' || run.toolName === 'edit') && typeof path === 'string' && PACKAGE_FILE.test(path);
|
|
23
|
+
})
|
|
24
|
+
.map(([id]) => id);
|
|
25
|
+
}
|
|
26
|
+
ChatUtil.packageEdits = packageEdits;
|
|
27
|
+
function message(error) {
|
|
28
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
|
+
}
|
|
30
|
+
ChatUtil.message = message;
|
|
31
|
+
/** Only the connection was lost: it mends itself, and what it cut off goes again once it is back. */
|
|
32
|
+
function lost(error) {
|
|
33
|
+
return ta_client_1.TaRemoteError.isConnectionLost(error);
|
|
34
|
+
}
|
|
35
|
+
ChatUtil.lost = lost;
|
|
36
|
+
/** A change nobody asked for now (after a run): a lost connection is no failure to tell, the next run does it again. */
|
|
37
|
+
function quietly(change) {
|
|
38
|
+
return () => change().catch(error => {
|
|
39
|
+
if (!lost(error)) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
ChatUtil.quietly = quietly;
|
|
45
|
+
/**
|
|
46
|
+
* Runs `run` again each time the connection is lost under it and comes back, while `wanted` (a few times
|
|
47
|
+
* at most): opening a conversation on a network that drops goes on, rather than failing.
|
|
48
|
+
*/
|
|
49
|
+
async function untilConnected(run, connected, wanted) {
|
|
50
|
+
for (let tries = 1;; tries++) {
|
|
51
|
+
try {
|
|
52
|
+
return await run();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (!lost(error) || tries >= 5 || !wanted()) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
await connected();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
ChatUtil.untilConnected = untilConnected;
|
|
63
|
+
})(ChatUtil || (exports.ChatUtil = ChatUtil = {}));
|
|
64
|
+
//# sourceMappingURL=chat-util.js.map
|
|
@@ -37,6 +37,7 @@ exports.useChat = useChat;
|
|
|
37
37
|
exports.Widget = Widget;
|
|
38
38
|
exports.ChatView = ChatView;
|
|
39
39
|
const react_1 = require("@celljs/react");
|
|
40
|
+
const ta_client_1 = require("@celljs/ta-client");
|
|
40
41
|
const lucide_react_1 = require("lucide-react");
|
|
41
42
|
const React = __importStar(require("react"));
|
|
42
43
|
const callout_1 = require("../components/callout");
|
|
@@ -45,6 +46,7 @@ const connection_bar_1 = require("../components/connection-bar");
|
|
|
45
46
|
const folder_picker_1 = require("../components/folder-picker");
|
|
46
47
|
const hero_cards_1 = require("../components/hero-cards");
|
|
47
48
|
const icon_1 = require("../components/icon");
|
|
49
|
+
const message_list_1 = require("../components/message-list");
|
|
48
50
|
const phone_shell_1 = require("../components/phone-shell");
|
|
49
51
|
const session_view_1 = require("../components/session-view");
|
|
50
52
|
const ta_avatar_1 = require("../components/ta-avatar");
|
|
@@ -91,24 +93,40 @@ function DraftView({ draft, menu, aboveComposer, belowComposer }) {
|
|
|
91
93
|
const list = React.useCallback((directory) => workbench.workspace.listDirectory('.', directory), [workbench]);
|
|
92
94
|
const pickModel = React.useCallback((model) => chat.setDraftModel(model), [chat]);
|
|
93
95
|
const model = (0, draft_model_1.useDraftModel)(workbench.settings, draft, pickModel, t);
|
|
96
|
+
const { sending } = draft;
|
|
97
|
+
const going = !!sending && !sending.failed;
|
|
98
|
+
// Its first message, as the conversation will show it, while the session opens.
|
|
99
|
+
const sent = React.useMemo(() => {
|
|
100
|
+
var _a;
|
|
101
|
+
if (!sending) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const message = {
|
|
105
|
+
role: 'user',
|
|
106
|
+
content: [{ type: 'text', text: sending.message }, ...((_a = sending.images) !== null && _a !== void 0 ? _a : [])],
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
};
|
|
109
|
+
return ta_client_1.SessionStore.withSent(ta_client_1.SessionReducer.initial(), [{ id: 'draft', message, failed: sending.failed }]);
|
|
110
|
+
}, [sending]);
|
|
111
|
+
const outbox = React.useMemo(() => ({ resend: () => void chat.resendDraft(), discard: () => chat.discardDraft() }), [chat]);
|
|
94
112
|
return (React.createElement("section", { className: "ta-session" },
|
|
95
113
|
React.createElement("header", { className: "ta-session-header" },
|
|
96
114
|
menu,
|
|
97
|
-
React.createElement("div", { className: "ta-session-title" },
|
|
98
|
-
React.createElement("span", { className: "ta-title" }, t('ta.
|
|
115
|
+
React.createElement("div", { className: "ta-session-title" }, going ? (React.createElement(React.Fragment, null,
|
|
116
|
+
React.createElement("span", { className: "ta-title" }, message_1.MessageUtil.basename(draft.cwd) || t('ta.session.title')),
|
|
117
|
+
React.createElement("span", { className: "ta-muted ta-path", title: draft.cwd }, message_1.MessageUtil.shortPath(draft.cwd)))) : (React.createElement("span", { className: "ta-title" }, t('ta.chat.new')))),
|
|
99
118
|
React.createElement(workbench_toggle_1.WorkbenchToggle, null)),
|
|
100
|
-
React.createElement("div", { className:
|
|
101
|
-
React.createElement("div", { className: "ta-thread" },
|
|
102
|
-
React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
|
|
119
|
+
React.createElement("div", { className: sent ? 'ta-scroll ta-conversation' : 'ta-scroll' },
|
|
120
|
+
React.createElement("div", { className: "ta-thread" }, sent ? React.createElement(message_list_1.MessageList, { state: sent, outbox: outbox }) : React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
|
|
103
121
|
React.createElement("div", { className: "ta-bottom" },
|
|
104
122
|
aboveComposer,
|
|
105
|
-
React.createElement(composer_1.Composer, { server: workbench.server, workspace: workbench.workspace, working:
|
|
123
|
+
React.createElement(composer_1.Composer, { server: workbench.server, workspace: workbench.workspace, working: going, onStop: () => chat.stopDraft(), commands: [], cwd: draft.cwd || undefined, onSubmit: submit, onError: fail, talkPlace: "draft", actions: model ? [[model]] : undefined, beside: going ? undefined : React.createElement(folder_picker_1.DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
|
|
106
124
|
belowComposer)));
|
|
107
125
|
}
|
|
108
126
|
/** A conversation picked that is still loading, laid out as it will be: its head, a spinner, a message box that waits. */
|
|
109
127
|
function OpeningView({ info, menu }) {
|
|
110
128
|
const t = (0, use_t_1.useT)();
|
|
111
|
-
const [, workbench] = (0, hooks_1.useWorkbench)();
|
|
129
|
+
const [{ offlineShown }, workbench] = (0, hooks_1.useWorkbench)();
|
|
112
130
|
return (React.createElement("section", { className: "ta-session", "aria-busy": "true" },
|
|
113
131
|
React.createElement("header", { className: "ta-session-header" },
|
|
114
132
|
menu,
|
|
@@ -116,16 +134,16 @@ function OpeningView({ info, menu }) {
|
|
|
116
134
|
React.createElement("span", { className: "ta-title" }, (info === null || info === void 0 ? void 0 : info.title) || ((info === null || info === void 0 ? void 0 : info.cwd) ? message_1.MessageUtil.basename(info.cwd) : t('ta.session.title'))),
|
|
117
135
|
(info === null || info === void 0 ? void 0 : info.cwd) && (React.createElement("span", { className: "ta-muted ta-path", title: info.cwd }, message_1.MessageUtil.shortPath(info.cwd)))),
|
|
118
136
|
React.createElement(workbench_toggle_1.WorkbenchToggle, null)),
|
|
119
|
-
React.createElement("div", { className: "ta-empty" },
|
|
137
|
+
React.createElement("div", { className: "ta-empty" }, offlineShown ? (React.createElement("span", { className: "ta-muted" }, t('ta.chat.openingOffline'))) : (React.createElement(React.Fragment, null,
|
|
120
138
|
React.createElement("span", { className: "ta-spinner" }),
|
|
121
139
|
" ",
|
|
122
|
-
t('ta.chat.opening')),
|
|
140
|
+
t('ta.chat.opening')))),
|
|
123
141
|
React.createElement("div", { className: "ta-bottom", inert: true },
|
|
124
142
|
React.createElement(composer_1.Composer, { server: workbench.server, workspace: workbench.workspace, working: false, commands: [], cwd: info === null || info === void 0 ? void 0 : info.cwd, onError: () => undefined }))));
|
|
125
143
|
}
|
|
126
144
|
/** The conversation shown, with the widgets of web extensions around its message box. */
|
|
127
145
|
function ChatView({ widgets, onMenu, back }) {
|
|
128
|
-
var _a, _b;
|
|
146
|
+
var _a, _b, _c, _d;
|
|
129
147
|
const t = (0, use_t_1.useT)();
|
|
130
148
|
const [{ sessions, saved }, workbench] = (0, hooks_1.useWorkbench)();
|
|
131
149
|
const [{ store, draft, pending, opening, error }] = useChat();
|
|
@@ -161,7 +179,10 @@ function ChatView({ widgets, onMenu, back }) {
|
|
|
161
179
|
" ",
|
|
162
180
|
t('ta.chat.opening'))))));
|
|
163
181
|
}
|
|
164
|
-
|
|
165
|
-
|
|
182
|
+
// One shown from the device under what is pending (a saved conversation, an agent's on its way) is said by what opens.
|
|
183
|
+
const info = (_b = sessions.find(session => session.sessionId === store.sessionId)) !== null && _b !== void 0 ? _b : (opening && pending === store.sessionId
|
|
184
|
+
? { sessionId: store.sessionId, sessionName: opening.title, cwd: (_c = opening.cwd) !== null && _c !== void 0 ? _c : '', sessionFile: opening.sessionFile }
|
|
185
|
+
: undefined);
|
|
186
|
+
return (React.createElement(session_view_1.SessionView, { key: store.sessionId, store: store, server: workbench.server, workspace: workbench.workspace, info: info, onClosed: refresh, onActivity: refresh, leading: menu, trailing: React.createElement(workbench_toggle_1.WorkbenchToggle, null), empty: React.createElement(Hero, { cwd: (_d = info === null || info === void 0 ? void 0 : info.cwd) !== null && _d !== void 0 ? _d : '', onPick: text => store.send(text).catch(() => undefined) }), aboveComposer: aboveComposer, belowComposer: around('belowEditor') }));
|
|
166
187
|
}
|
|
167
188
|
//# sourceMappingURL=chat-view.js.map
|