@celljs/ta-web 4.12.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/assistant/assistant-extension.js +14 -0
- package/esm/browser/assistant/assistant-initiative.d.ts +27 -0
- package/esm/browser/assistant/assistant-initiative.js +76 -0
- package/esm/browser/assistant/assistant-task-source.d.ts +7 -0
- package/esm/browser/assistant/assistant-task-source.js +12 -2
- package/esm/browser/assistant/assistant-view.js +5 -4
- package/esm/browser/assistant/assistant.d.ts +5 -0
- package/esm/browser/assistant/assistant.js +25 -6
- package/esm/browser/components/app-nav.d.ts +3 -1
- package/esm/browser/components/app-nav.js +5 -2
- package/esm/browser/components/app-view.js +18 -9
- package/esm/browser/components/asks-badge.d.ts +5 -0
- package/esm/browser/components/asks-badge.js +8 -0
- package/esm/browser/components/chat-asks.d.ts +46 -0
- package/esm/browser/components/chat-asks.js +101 -0
- package/esm/browser/components/chat-list.d.ts +7 -1
- package/esm/browser/components/chat-list.js +46 -17
- package/esm/browser/components/composer-addon-util.d.ts +11 -0
- package/esm/browser/components/composer-addon-util.js +40 -0
- package/esm/browser/components/composer-addons.d.ts +1 -7
- package/esm/browser/components/composer-addons.js +1 -27
- package/esm/browser/components/composer.d.ts +7 -1
- package/esm/browser/components/composer.js +33 -20
- package/esm/browser/components/connection-bar.js +31 -12
- package/esm/browser/components/conversation-scroll-util.d.ts +5 -0
- package/esm/browser/components/conversation-scroll-util.js +18 -0
- package/esm/browser/components/conversation-scroll.d.ts +12 -2
- package/esm/browser/components/conversation-scroll.js +68 -5
- package/esm/browser/components/discover-view.js +5 -1
- package/esm/browser/components/earlier-messages.d.ts +10 -3
- package/esm/browser/components/earlier-messages.js +14 -8
- package/esm/browser/components/folder-picker.d.ts +2 -0
- package/esm/browser/components/folder-picker.js +7 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/markdown.js +4 -2
- package/esm/browser/components/media.js +4 -39
- package/esm/browser/components/mermaid-view.js +45 -3
- package/esm/browser/components/message-footer.d.ts +2 -0
- package/esm/browser/components/message-footer.js +8 -1
- package/esm/browser/components/message-list.d.ts +12 -0
- package/esm/browser/components/message-list.js +156 -25
- package/esm/browser/components/phone-shell.d.ts +7 -2
- package/esm/browser/components/phone-shell.js +7 -3
- package/esm/browser/components/relay-services.d.ts +24 -0
- package/esm/browser/components/relay-services.js +249 -0
- package/esm/browser/components/relay-view.js +17 -1
- package/esm/browser/components/remote-hosts.js +1 -1
- package/esm/browser/components/session-view.js +16 -4
- package/esm/browser/components/settings-controls.js +3 -3
- package/esm/browser/components/settings-parts.js +13 -1
- package/esm/browser/components/ta-avatar.js +6 -0
- package/esm/browser/components/tool-result.d.ts +13 -0
- package/esm/browser/components/tool-result.js +138 -0
- package/esm/browser/components/tool-view.js +5 -15
- package/esm/browser/components/web-composer.js +2 -1
- package/esm/browser/extension/extension-view.d.ts +3 -1
- package/esm/browser/extension/extension-view.js +7 -0
- package/esm/browser/extension/icons.js +9 -1
- package/esm/browser/extension/web-api-components.d.ts +3 -3
- package/esm/browser/extension/web-api-contributions.d.ts +119 -0
- package/esm/browser/extension/web-extension-api.d.ts +23 -46
- package/esm/browser/extension/web-extension-context.d.ts +6 -1
- package/esm/browser/extension/web-extension-context.js +63 -6
- package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
- package/esm/browser/extension/web-extension-protocol.js +1 -0
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +3 -0
- package/esm/browser/extension/web-extensions.d.ts +2 -8
- package/esm/browser/extension/web-extensions.js +9 -35
- package/esm/browser/extension/web-page-list.d.ts +25 -0
- package/esm/browser/extension/web-page-list.js +35 -0
- package/esm/browser/extension/web-session-notices.d.ts +6 -1
- package/esm/browser/extension/web-session-notices.js +30 -4
- package/esm/browser/extension/web-sharing.d.ts +5 -2
- package/esm/browser/extension/web-sharing.js +10 -1
- package/esm/browser/i18n/locales.d.ts +69 -3
- package/esm/browser/i18n/messages.d.ts +68 -2
- package/esm/browser/i18n/messages.js +138 -6
- package/esm/browser/markdown/code-renderers.d.ts +4 -0
- package/esm/browser/markdown/code-renderers.js +4 -0
- package/esm/browser/markdown/lazy.d.ts +8 -0
- package/esm/browser/markdown/lazy.js +35 -0
- package/esm/browser/markdown/mermaid.d.ts +15 -3
- package/esm/browser/markdown/mermaid.js +45 -6
- package/esm/browser/notices/notices-protocol.d.ts +5 -0
- package/esm/browser/notices/notices.d.ts +19 -0
- package/esm/browser/notices/notices.js +85 -2
- package/esm/browser/notices/session-notices.d.ts +5 -2
- package/esm/browser/notices/session-notices.js +10 -1
- package/esm/browser/style/base.d.ts +1 -1
- package/esm/browser/style/base.js +2 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +51 -0
- package/esm/browser/style/device.js +3 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +24 -9
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -0
- package/esm/browser/style/phone.d.ts +1 -1
- package/esm/browser/style/phone.js +2 -0
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +14 -3
- package/esm/browser/util/desktop.d.ts +18 -1
- package/esm/browser/util/desktop.js +13 -0
- package/esm/browser/util/process.d.ts +26 -1
- package/esm/browser/util/process.js +79 -5
- package/esm/browser/util/progress.d.ts +6 -1
- package/esm/browser/util/progress.js +11 -2
- package/esm/browser/util/scroll-rest.d.ts +10 -0
- package/esm/browser/util/scroll-rest.js +44 -0
- package/esm/browser/util/tool-result.d.ts +32 -0
- package/esm/browser/util/tool-result.js +85 -0
- package/esm/browser/util/tool.js +7 -0
- package/lib/browser/assistant/assistant-extension.js +14 -0
- package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
- package/lib/browser/assistant/assistant-initiative.js +80 -0
- package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
- package/lib/browser/assistant/assistant-task-source.js +12 -2
- package/lib/browser/assistant/assistant-view.js +3 -2
- package/lib/browser/assistant/assistant.d.ts +5 -0
- package/lib/browser/assistant/assistant.js +24 -5
- package/lib/browser/components/app-nav.d.ts +3 -1
- package/lib/browser/components/app-nav.js +5 -2
- package/lib/browser/components/app-view.js +17 -8
- package/lib/browser/components/asks-badge.d.ts +6 -0
- package/lib/browser/components/asks-badge.js +44 -0
- package/lib/browser/components/chat-asks.d.ts +47 -0
- package/lib/browser/components/chat-asks.js +104 -0
- package/lib/browser/components/chat-list.d.ts +7 -1
- package/lib/browser/components/chat-list.js +46 -17
- package/lib/browser/components/composer-addon-util.d.ts +12 -0
- package/lib/browser/components/composer-addon-util.js +76 -0
- package/lib/browser/components/composer-addons.d.ts +1 -7
- package/lib/browser/components/composer-addons.js +2 -29
- package/lib/browser/components/composer.d.ts +7 -1
- package/lib/browser/components/composer.js +33 -19
- package/lib/browser/components/connection-bar.js +30 -11
- package/lib/browser/components/conversation-scroll-util.d.ts +5 -0
- package/lib/browser/components/conversation-scroll-util.js +18 -0
- package/lib/browser/components/conversation-scroll.d.ts +12 -2
- package/lib/browser/components/conversation-scroll.js +68 -5
- package/lib/browser/components/discover-view.js +5 -1
- package/lib/browser/components/earlier-messages.d.ts +10 -3
- package/lib/browser/components/earlier-messages.js +16 -9
- package/lib/browser/components/folder-picker.d.ts +2 -0
- package/lib/browser/components/folder-picker.js +7 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/markdown.js +3 -1
- package/lib/browser/components/media.js +3 -38
- package/lib/browser/components/mermaid-view.js +45 -3
- package/lib/browser/components/message-footer.d.ts +2 -0
- package/lib/browser/components/message-footer.js +8 -0
- package/lib/browser/components/message-list.d.ts +12 -0
- package/lib/browser/components/message-list.js +153 -20
- package/lib/browser/components/phone-shell.d.ts +7 -2
- package/lib/browser/components/phone-shell.js +7 -3
- package/lib/browser/components/relay-services.d.ts +25 -0
- package/lib/browser/components/relay-services.js +286 -0
- package/lib/browser/components/relay-view.js +17 -1
- package/lib/browser/components/remote-hosts.js +1 -1
- package/lib/browser/components/session-view.js +15 -3
- package/lib/browser/components/settings-controls.js +3 -3
- package/lib/browser/components/settings-parts.js +13 -1
- package/lib/browser/components/ta-avatar.js +6 -0
- package/lib/browser/components/tool-result.d.ts +14 -0
- package/lib/browser/components/tool-result.js +175 -0
- package/lib/browser/components/tool-view.js +10 -20
- package/lib/browser/components/web-composer.js +2 -1
- package/lib/browser/extension/extension-view.d.ts +3 -1
- package/lib/browser/extension/extension-view.js +8 -1
- package/lib/browser/extension/icons.js +8 -0
- package/lib/browser/extension/web-api-components.d.ts +3 -3
- package/lib/browser/extension/web-api-contributions.d.ts +119 -0
- package/lib/browser/extension/web-extension-api.d.ts +23 -46
- package/lib/browser/extension/web-extension-context.d.ts +6 -1
- package/lib/browser/extension/web-extension-context.js +63 -6
- package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
- package/lib/browser/extension/web-extension-protocol.js +1 -0
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +3 -0
- package/lib/browser/extension/web-extensions.d.ts +2 -8
- package/lib/browser/extension/web-extensions.js +9 -35
- package/lib/browser/extension/web-page-list.d.ts +26 -0
- package/lib/browser/extension/web-page-list.js +39 -0
- package/lib/browser/extension/web-session-notices.d.ts +6 -1
- package/lib/browser/extension/web-session-notices.js +30 -4
- package/lib/browser/extension/web-sharing.d.ts +5 -2
- package/lib/browser/extension/web-sharing.js +10 -1
- package/lib/browser/i18n/locales.d.ts +69 -3
- package/lib/browser/i18n/messages.d.ts +68 -2
- package/lib/browser/i18n/messages.js +138 -6
- package/lib/browser/markdown/code-renderers.d.ts +4 -0
- package/lib/browser/markdown/code-renderers.js +5 -1
- package/lib/browser/markdown/lazy.d.ts +8 -0
- package/lib/browser/markdown/lazy.js +37 -1
- package/lib/browser/markdown/mermaid.d.ts +15 -3
- package/lib/browser/markdown/mermaid.js +44 -5
- package/lib/browser/notices/notices-protocol.d.ts +5 -0
- package/lib/browser/notices/notices.d.ts +19 -0
- package/lib/browser/notices/notices.js +84 -1
- package/lib/browser/notices/session-notices.d.ts +5 -2
- package/lib/browser/notices/session-notices.js +10 -1
- package/lib/browser/style/base.d.ts +1 -1
- package/lib/browser/style/base.js +2 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +51 -0
- package/lib/browser/style/device.js +3 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +24 -9
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -0
- package/lib/browser/style/phone.d.ts +1 -1
- package/lib/browser/style/phone.js +2 -0
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +14 -3
- package/lib/browser/util/desktop.d.ts +18 -1
- package/lib/browser/util/desktop.js +13 -0
- package/lib/browser/util/process.d.ts +26 -1
- package/lib/browser/util/process.js +79 -5
- package/lib/browser/util/progress.d.ts +6 -1
- package/lib/browser/util/progress.js +11 -2
- package/lib/browser/util/scroll-rest.d.ts +11 -0
- package/lib/browser/util/scroll-rest.js +47 -0
- package/lib/browser/util/tool-result.d.ts +33 -0
- package/lib/browser/util/tool-result.js +88 -0
- package/lib/browser/util/tool.js +7 -0
- package/package.json +7 -7
|
@@ -38,7 +38,8 @@ export var ProgressUtil;
|
|
|
38
38
|
case 'compacting':
|
|
39
39
|
return t('ta.progress.compacting');
|
|
40
40
|
case 'retrying': {
|
|
41
|
-
const
|
|
41
|
+
const error = phase.reason === 'error' ? ProgressUtil.brief(phase.error) : '';
|
|
42
|
+
const reason = error || t(`ta.progress.retry.${phase.reason}`);
|
|
42
43
|
const seconds = (_b = options.secondsLeft) !== null && _b !== void 0 ? _b : phase.seconds;
|
|
43
44
|
return seconds > 0
|
|
44
45
|
? t('ta.progress.retrying', { reason, seconds, attempt: phase.attempt, max: phase.maxAttempts })
|
|
@@ -58,7 +59,9 @@ export var ProgressUtil;
|
|
|
58
59
|
}
|
|
59
60
|
if (state.retry) {
|
|
60
61
|
const { attempt, maxAttempts, delayMs, errorMessage } = state.retry;
|
|
61
|
-
|
|
62
|
+
const reason = retryReason(errorMessage);
|
|
63
|
+
const seconds = Math.max(1, Math.round(delayMs / 1000));
|
|
64
|
+
return { kind: 'retrying', attempt, maxAttempts, seconds, reason, ...(reason === 'error' && errorMessage ? { error: errorMessage } : {}) };
|
|
62
65
|
}
|
|
63
66
|
const [request] = state.pendingClientTools;
|
|
64
67
|
if (request) {
|
|
@@ -87,6 +90,12 @@ export var ProgressUtil;
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
ProgressUtil.phase = phase;
|
|
93
|
+
/** The first line of an error, short enough for the loading line. */
|
|
94
|
+
function brief(error, length = 60) {
|
|
95
|
+
const line = (error !== null && error !== void 0 ? error : '').trim().split('\n')[0].trim();
|
|
96
|
+
return line.length > length ? `${line.slice(0, length - 1)}…` : line;
|
|
97
|
+
}
|
|
98
|
+
ProgressUtil.brief = brief;
|
|
90
99
|
/** Why a request failed, as the provider said it: a rate limit, a model too busy, the network, or another error. */
|
|
91
100
|
function retryReason(errorMessage) {
|
|
92
101
|
const message = errorMessage !== null && errorMessage !== void 0 ? errorMessage : '';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the user scrolls the page, anywhere in it: what costs a frame and need not happen now (a diagram drawn,
|
|
3
|
+
* the avatars moving) waits for it to rest, QUIET_MS without a scroll and no finger on it, for a fling not to stutter.
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace ScrollRest {
|
|
6
|
+
/** Whether the page scrolls now (or a finger holds it). */
|
|
7
|
+
function moving(now?: number): boolean;
|
|
8
|
+
/** Once the page rests, or WAIT_MS at most. */
|
|
9
|
+
function wait(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the user scrolls the page, anywhere in it: what costs a frame and need not happen now (a diagram drawn,
|
|
3
|
+
* the avatars moving) waits for it to rest, QUIET_MS without a scroll and no finger on it, for a fling not to stutter.
|
|
4
|
+
*/
|
|
5
|
+
export var ScrollRest;
|
|
6
|
+
(function (ScrollRest) {
|
|
7
|
+
const QUIET_MS = 150;
|
|
8
|
+
/** At most this long: what follows a reply streaming scrolls on and on. */
|
|
9
|
+
const WAIT_MS = 1000;
|
|
10
|
+
let last = Number.NEGATIVE_INFINITY;
|
|
11
|
+
let touching = false;
|
|
12
|
+
let listening = false;
|
|
13
|
+
function listen() {
|
|
14
|
+
if (listening || typeof document === 'undefined') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
listening = true;
|
|
18
|
+
const passive = { capture: true, passive: true };
|
|
19
|
+
document.addEventListener('scroll', () => (last = performance.now()), passive);
|
|
20
|
+
document.addEventListener('touchstart', () => (touching = true), passive);
|
|
21
|
+
const lifted = (event) => {
|
|
22
|
+
touching = event.touches.length > 0;
|
|
23
|
+
last = performance.now();
|
|
24
|
+
};
|
|
25
|
+
document.addEventListener('touchend', lifted, passive);
|
|
26
|
+
document.addEventListener('touchcancel', lifted, passive);
|
|
27
|
+
}
|
|
28
|
+
/** Whether the page scrolls now (or a finger holds it). */
|
|
29
|
+
function moving(now = performance.now()) {
|
|
30
|
+
listen();
|
|
31
|
+
return touching || now - last < QUIET_MS;
|
|
32
|
+
}
|
|
33
|
+
ScrollRest.moving = moving;
|
|
34
|
+
/** Once the page rests, or WAIT_MS at most. */
|
|
35
|
+
async function wait() {
|
|
36
|
+
listen();
|
|
37
|
+
const until = performance.now() + WAIT_MS;
|
|
38
|
+
for (let now = performance.now(); now < until && moving(now); now = performance.now()) {
|
|
39
|
+
await new Promise(resolve => setTimeout(resolve, Math.max(16, QUIET_MS - (now - last))));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
ScrollRest.wait = wait;
|
|
43
|
+
})(ScrollRest || (ScrollRest = {}));
|
|
44
|
+
//# sourceMappingURL=scroll-rest.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** What an external agent's tool wrote when it returned nothing (`AgentTool` of @celljs/ta-agents). */
|
|
2
|
+
export declare const NO_OUTPUT = "(no output)";
|
|
3
|
+
/** What a script returned, the shape code mode scripts of agents answer with. */
|
|
4
|
+
export interface ScriptResult {
|
|
5
|
+
result: unknown;
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
failures: {
|
|
9
|
+
tool: string;
|
|
10
|
+
error: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/** What a command printed. */
|
|
14
|
+
export interface ShellResult {
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
exitCode?: number;
|
|
18
|
+
}
|
|
19
|
+
/** The output of a tool as a person reads it: JSON opened, the colors of a terminal left out. */
|
|
20
|
+
export declare namespace ResultUtil {
|
|
21
|
+
function clean(text: string): string;
|
|
22
|
+
/** The object or array a text holds, when the whole text is JSON of one. */
|
|
23
|
+
function json(text: string): object | undefined;
|
|
24
|
+
/** A script's answer: `{ result, stdout, stderr, toolFailures }`, the result being what it returned. */
|
|
25
|
+
function script(value: unknown): ScriptResult | undefined;
|
|
26
|
+
/** What a command printed: `{ stdout, stderr, exitCode }`. */
|
|
27
|
+
function shell(value: unknown): ShellResult | undefined;
|
|
28
|
+
/** Whether a value shows in the line of its key: a number, a word, a short line. */
|
|
29
|
+
function inline(value: unknown): boolean;
|
|
30
|
+
/** How a value that shows in a line reads. */
|
|
31
|
+
function atom(value: unknown): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** What an external agent's tool wrote when it returned nothing (`AgentTool` of @celljs/ta-agents). */
|
|
2
|
+
export const NO_OUTPUT = '(no output)';
|
|
3
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: the escape that starts a color of a terminal
|
|
4
|
+
const ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
5
|
+
const SCRIPT_KEYS = new Set(['result', 'stdout', 'stderr', 'toolFailures', 'toolFailureNotice']);
|
|
6
|
+
const SHELL_KEYS = new Set(['stdout', 'stderr', 'exitCode', 'signal', 'interrupted', 'denied', 'sandboxHint']);
|
|
7
|
+
/** The longest string shown in a line beside its key. */
|
|
8
|
+
const INLINE_CHARS = 72;
|
|
9
|
+
function str(value) {
|
|
10
|
+
return typeof value === 'string' ? value : '';
|
|
11
|
+
}
|
|
12
|
+
function record(value) {
|
|
13
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
/** The output of a tool as a person reads it: JSON opened, the colors of a terminal left out. */
|
|
16
|
+
export var ResultUtil;
|
|
17
|
+
(function (ResultUtil) {
|
|
18
|
+
function clean(text) {
|
|
19
|
+
return text.replace(ANSI, '').replace(/\n+$/, '');
|
|
20
|
+
}
|
|
21
|
+
ResultUtil.clean = clean;
|
|
22
|
+
/** The object or array a text holds, when the whole text is JSON of one. */
|
|
23
|
+
function json(text) {
|
|
24
|
+
const trimmed = text.trim();
|
|
25
|
+
if (!/^[[{]/.test(trimmed)) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const value = JSON.parse(trimmed);
|
|
30
|
+
return value && typeof value === 'object' ? value : undefined;
|
|
31
|
+
}
|
|
32
|
+
catch (_a) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
ResultUtil.json = json;
|
|
37
|
+
/** A script's answer: `{ result, stdout, stderr, toolFailures }`, the result being what it returned. */
|
|
38
|
+
function script(value) {
|
|
39
|
+
var _a;
|
|
40
|
+
const object = record(value);
|
|
41
|
+
if (!object || !('result' in object) || !Object.keys(object).every(key => SCRIPT_KEYS.has(key))) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const calls = (_a = record(object.toolFailures)) === null || _a === void 0 ? void 0 : _a.calls;
|
|
45
|
+
const failures = (Array.isArray(calls) ? calls : []).map(call => { var _a, _b; return ({
|
|
46
|
+
tool: str((_a = record(call)) === null || _a === void 0 ? void 0 : _a.tool),
|
|
47
|
+
error: clean(str((_b = record(call)) === null || _b === void 0 ? void 0 : _b.error)),
|
|
48
|
+
}); });
|
|
49
|
+
return { result: object.result, stdout: clean(str(object.stdout)), stderr: clean(str(object.stderr)), failures };
|
|
50
|
+
}
|
|
51
|
+
ResultUtil.script = script;
|
|
52
|
+
/** What a command printed: `{ stdout, stderr, exitCode }`. */
|
|
53
|
+
function shell(value) {
|
|
54
|
+
const object = record(value);
|
|
55
|
+
if (!object || typeof object.stdout !== 'string' || !('stderr' in object || 'exitCode' in object)) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (!Object.keys(object).every(key => SHELL_KEYS.has(key))) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const exitCode = typeof object.exitCode === 'number' ? object.exitCode : undefined;
|
|
62
|
+
return { stdout: clean(object.stdout), stderr: clean(str(object.stderr)), exitCode };
|
|
63
|
+
}
|
|
64
|
+
ResultUtil.shell = shell;
|
|
65
|
+
/** Whether a value shows in the line of its key: a number, a word, a short line. */
|
|
66
|
+
function inline(value) {
|
|
67
|
+
if (typeof value === 'string') {
|
|
68
|
+
return value.length <= INLINE_CHARS && !value.includes('\n') && !json(value);
|
|
69
|
+
}
|
|
70
|
+
return value === null || typeof value !== 'object' || (Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0);
|
|
71
|
+
}
|
|
72
|
+
ResultUtil.inline = inline;
|
|
73
|
+
/** How a value that shows in a line reads. */
|
|
74
|
+
function atom(value) {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return '[]';
|
|
77
|
+
}
|
|
78
|
+
if (value && typeof value === 'object') {
|
|
79
|
+
return '{}';
|
|
80
|
+
}
|
|
81
|
+
return typeof value === 'string' ? value || '""' : String(value);
|
|
82
|
+
}
|
|
83
|
+
ResultUtil.atom = atom;
|
|
84
|
+
})(ResultUtil || (ResultUtil = {}));
|
|
85
|
+
//# sourceMappingURL=tool-result.js.map
|
package/esm/browser/util/tool.js
CHANGED
|
@@ -49,6 +49,13 @@ const AGENT_TOOL_VERBS = {
|
|
|
49
49
|
TaskOutput: 'ta.tool.verb.getTask',
|
|
50
50
|
TaskStop: 'ta.tool.verb.stopTask',
|
|
51
51
|
Skill: 'ta.tool.verb.skill',
|
|
52
|
+
SendMessage: 'ta.tool.verb.sendMessage',
|
|
53
|
+
TeamDelete: 'ta.tool.verb.deleteTeam',
|
|
54
|
+
CronCreate: 'ta.tool.verb.scheduleTask',
|
|
55
|
+
CronList: 'ta.tool.verb.listScheduled',
|
|
56
|
+
CronDelete: 'ta.tool.verb.deleteScheduled',
|
|
57
|
+
Artifact: 'ta.tool.verb.publish',
|
|
58
|
+
ImageEdit: 'ta.tool.verb.editImage',
|
|
52
59
|
};
|
|
53
60
|
const TARGET_CHARS = 160;
|
|
54
61
|
function str(value) {
|
|
@@ -46,6 +46,7 @@ exports.AssistantWebExtension = void 0;
|
|
|
46
46
|
const core_1 = require("@celljs/core");
|
|
47
47
|
const lucide_react_1 = require("lucide-react");
|
|
48
48
|
const React = __importStar(require("react"));
|
|
49
|
+
const chat_asks_1 = require("../components/chat-asks");
|
|
49
50
|
const dino_look_picker_1 = require("../components/dino-look-picker");
|
|
50
51
|
const web_extension_protocol_1 = require("../extension/web-extension-protocol");
|
|
51
52
|
const messages_1 = require("../i18n/messages");
|
|
@@ -132,6 +133,19 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
132
133
|
openDouble: () => pi.ui.showView(`${assistant_view_1.ASSISTANT_NAME}/assistant`),
|
|
133
134
|
menu: taskMenu,
|
|
134
135
|
remove,
|
|
136
|
+
asking: task => {
|
|
137
|
+
var _a;
|
|
138
|
+
const info = this.workbench.state.sessions.find(each => each.sessionId === task.sessionId);
|
|
139
|
+
return info && ((_a = chat_asks_1.ChatAskUtil.asking(info, this.persisted.get(chat_asks_1.LET_GO_ASKS))) === null || _a === void 0 ? void 0 : _a.question);
|
|
140
|
+
},
|
|
141
|
+
watchAsking: listener => {
|
|
142
|
+
const stops = [this.workbench.subscribe(() => listener()), this.persisted.subscribe(() => listener())];
|
|
143
|
+
return () => {
|
|
144
|
+
for (const stop of stops) {
|
|
145
|
+
stop();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
},
|
|
135
149
|
});
|
|
136
150
|
pi.registerTasks(tasks);
|
|
137
151
|
const registerPage = () => pi.registerView('assistant', {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { WebInitiative, WebInitiativeKind } from '../extension/web-api-contributions';
|
|
2
|
+
import type { TaWebExtensions } from '../extension/web-extension-protocol';
|
|
3
|
+
import type { Settings, TaSettings } from '../settings/settings-protocol';
|
|
4
|
+
/** The double starting a task it hands out: by default without asking, as pi asks nothing (Settings.confirmTasks). */
|
|
5
|
+
export declare const START_TASK: WebInitiativeKind;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the double asks before it starts a task, kept with the extension that keeps the user's trust when there is
|
|
8
|
+
* one (WebExtensionAPI.registerInitiative): its level drives Settings.confirmTasks (`act` does not ask), what the user
|
|
9
|
+
* answers moves it, and the user's own switch (the + of the box, the settings) is kept there as their choice. Without
|
|
10
|
+
* one, Settings.confirmTasks alone, as before.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AssistantInitiative {
|
|
13
|
+
protected readonly extensions: () => TaWebExtensions | undefined;
|
|
14
|
+
protected readonly settings: () => TaSettings;
|
|
15
|
+
/** Settings.confirmTasks as the level last made it: a change to another value is the user's. */
|
|
16
|
+
protected synced?: boolean;
|
|
17
|
+
protected current?: WebInitiative;
|
|
18
|
+
protected unwatch?: () => void;
|
|
19
|
+
protected unwatchProvider?: () => void;
|
|
20
|
+
constructor(extensions: () => TaWebExtensions | undefined, settings: () => TaSettings);
|
|
21
|
+
start(): void;
|
|
22
|
+
/** The settings changed: a new value of Settings.confirmTasks not of the level is the user's, kept as their choice. */
|
|
23
|
+
settingsChanged(settings: Settings): void;
|
|
24
|
+
/** What the user answered when the double asked. */
|
|
25
|
+
record(outcome: 'accepted' | 'declined', title: string): void;
|
|
26
|
+
protected sync(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=assistant-initiative.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssistantInitiative = exports.START_TASK = void 0;
|
|
4
|
+
/** The double starting a task it hands out: by default without asking, as pi asks nothing (Settings.confirmTasks). */
|
|
5
|
+
exports.START_TASK = {
|
|
6
|
+
id: 'double.start-task',
|
|
7
|
+
title: { en: 'The double starts the tasks it hands out', zh: '分身开始它交出的任务' },
|
|
8
|
+
reversible: true,
|
|
9
|
+
level: 'act',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether the double asks before it starts a task, kept with the extension that keeps the user's trust when there is
|
|
13
|
+
* one (WebExtensionAPI.registerInitiative): its level drives Settings.confirmTasks (`act` does not ask), what the user
|
|
14
|
+
* answers moves it, and the user's own switch (the + of the box, the settings) is kept there as their choice. Without
|
|
15
|
+
* one, Settings.confirmTasks alone, as before.
|
|
16
|
+
*/
|
|
17
|
+
class AssistantInitiative {
|
|
18
|
+
constructor(extensions, settings) {
|
|
19
|
+
this.extensions = extensions;
|
|
20
|
+
this.settings = settings;
|
|
21
|
+
}
|
|
22
|
+
start() {
|
|
23
|
+
const extensions = this.extensions();
|
|
24
|
+
if (this.unwatch || !extensions) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const pick = () => {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
const next = (_a = extensions.state.initiatives) === null || _a === void 0 ? void 0 : _a[0];
|
|
30
|
+
if (next === this.current) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
(_b = this.unwatchProvider) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
34
|
+
this.current = next;
|
|
35
|
+
this.synced = undefined;
|
|
36
|
+
this.unwatchProvider = (_c = next === null || next === void 0 ? void 0 : next.subscribe) === null || _c === void 0 ? void 0 : _c.call(next, () => void this.sync());
|
|
37
|
+
void this.sync();
|
|
38
|
+
};
|
|
39
|
+
this.unwatch = extensions.subscribe(pick);
|
|
40
|
+
pick();
|
|
41
|
+
}
|
|
42
|
+
/** The settings changed: a new value of Settings.confirmTasks not of the level is the user's, kept as their choice. */
|
|
43
|
+
settingsChanged(settings) {
|
|
44
|
+
const provider = this.current;
|
|
45
|
+
if (!provider || this.synced === undefined || settings.confirmTasks === this.synced) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.synced = settings.confirmTasks;
|
|
49
|
+
void provider.setLevel(exports.START_TASK, settings.confirmTasks ? 'ask' : 'act').catch(() => undefined);
|
|
50
|
+
}
|
|
51
|
+
/** What the user answered when the double asked. */
|
|
52
|
+
record(outcome, title) {
|
|
53
|
+
var _a;
|
|
54
|
+
void ((_a = this.current) === null || _a === void 0 ? void 0 : _a.record(exports.START_TASK, outcome, title).catch(() => undefined));
|
|
55
|
+
}
|
|
56
|
+
async sync() {
|
|
57
|
+
const provider = this.current;
|
|
58
|
+
if (!provider) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const asking = (await provider.level(exports.START_TASK).catch(() => undefined)) !== 'act';
|
|
62
|
+
if (provider !== this.current) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const settings = this.settings();
|
|
66
|
+
const now = settings.state.settings.confirmTasks;
|
|
67
|
+
// The first time: the user turned asking on before a level was kept, which is their choice.
|
|
68
|
+
if (this.synced === undefined && now && !asking) {
|
|
69
|
+
this.synced = true;
|
|
70
|
+
await provider.setLevel(exports.START_TASK, 'ask').catch(() => undefined);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.synced = asking;
|
|
74
|
+
if (now !== asking) {
|
|
75
|
+
settings.update({ confirmTasks: asking });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.AssistantInitiative = AssistantInitiative;
|
|
80
|
+
//# sourceMappingURL=assistant-initiative.js.map
|
|
@@ -13,6 +13,12 @@ export interface AssistantTaskActions {
|
|
|
13
13
|
menu(task: AssistantTask): WebMenuItem[][];
|
|
14
14
|
/** Deletes it without asking (WebTask.remove). */
|
|
15
15
|
remove(task: AssistantTask): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* What the conversation of a task asks the user to decide, its turn over (TaSessionInfo.asking, unless let go):
|
|
18
|
+
* the task waits for them. `watchAsking` tells when that may have changed (the list of sessions, what was let go).
|
|
19
|
+
*/
|
|
20
|
+
asking?(task: AssistantTask): string | undefined;
|
|
21
|
+
watchAsking?(listener: () => void): () => void;
|
|
16
22
|
}
|
|
17
23
|
/** What of a task's session the list shows: a new task object only when it changes. */
|
|
18
24
|
interface Shown {
|
|
@@ -39,6 +45,7 @@ export declare class AssistantTaskSource implements WebTaskSource {
|
|
|
39
45
|
}>;
|
|
40
46
|
protected readonly listeners: Set<() => void>;
|
|
41
47
|
protected stopAssistant?: () => void;
|
|
48
|
+
protected stopAsking?: () => void;
|
|
42
49
|
constructor(assistant: TaAssistant, actions: AssistantTaskActions);
|
|
43
50
|
tasks(): readonly WebTask[];
|
|
44
51
|
subscribe(listener: () => void): () => void;
|
|
@@ -32,8 +32,10 @@ class AssistantTaskSource {
|
|
|
32
32
|
return this.list;
|
|
33
33
|
}
|
|
34
34
|
subscribe(listener) {
|
|
35
|
+
var _a, _b;
|
|
35
36
|
if (this.listeners.size === 0) {
|
|
36
37
|
this.stopAssistant = this.assistant.subscribe(state => this.sync(state));
|
|
38
|
+
this.stopAsking = (_b = (_a = this.actions).watchAsking) === null || _b === void 0 ? void 0 : _b.call(_a, () => this.build());
|
|
37
39
|
this.sync(this.assistant.state);
|
|
38
40
|
// The lists show them before the double is opened.
|
|
39
41
|
void this.assistant.loadTasks().catch(() => undefined);
|
|
@@ -52,9 +54,11 @@ class AssistantTaskSource {
|
|
|
52
54
|
this.sync(this.assistant.state);
|
|
53
55
|
}
|
|
54
56
|
dispose() {
|
|
55
|
-
var _a;
|
|
57
|
+
var _a, _b;
|
|
56
58
|
(_a = this.stopAssistant) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
57
59
|
this.stopAssistant = undefined;
|
|
60
|
+
(_b = this.stopAsking) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
61
|
+
this.stopAsking = undefined;
|
|
58
62
|
for (const { stop } of this.stores.values()) {
|
|
59
63
|
stop();
|
|
60
64
|
}
|
|
@@ -113,18 +117,24 @@ class AssistantTaskSource {
|
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
status(task, state) {
|
|
120
|
+
var _a, _b;
|
|
116
121
|
if (task.status === 'running' && state && state.pendingUi.length > 0) {
|
|
117
122
|
return 'waiting';
|
|
118
123
|
}
|
|
124
|
+
if (task.status !== 'running' && !task.takenOver && ((_b = (_a = this.actions).asking) === null || _b === void 0 ? void 0 : _b.call(_a, task))) {
|
|
125
|
+
return 'waiting';
|
|
126
|
+
}
|
|
119
127
|
return task.status;
|
|
120
128
|
}
|
|
121
129
|
detail(task, status, state) {
|
|
130
|
+
var _a, _b;
|
|
122
131
|
const { t } = this.actions;
|
|
123
132
|
if (task.takenOver) {
|
|
124
133
|
return t('ta.task.takenOver');
|
|
125
134
|
}
|
|
126
135
|
if (status === 'waiting') {
|
|
127
|
-
|
|
136
|
+
const asking = task.status === 'running' ? undefined : (_b = (_a = this.actions).asking) === null || _b === void 0 ? void 0 : _b.call(_a, task);
|
|
137
|
+
return asking ? t('ta.chat.toAsk', { question: asking }) : t('ta.task.waiting');
|
|
128
138
|
}
|
|
129
139
|
return activity(task, state, t);
|
|
130
140
|
}
|
|
@@ -115,9 +115,9 @@ function moodOf({ working, attention, listening, speaking, running, recentlyDone
|
|
|
115
115
|
}
|
|
116
116
|
/** `index`: in the whole conversation, of which `messages` start at `start`. */
|
|
117
117
|
/** What the user said; a task that reports back stays where it comes in. */
|
|
118
|
-
const saidByUser = (message) => {
|
|
118
|
+
const saidByUser = (message, index, messages) => {
|
|
119
119
|
const text = message_1.MessageUtil.text(message_1.MessageUtil.blocks(message)).trim();
|
|
120
|
-
return message
|
|
120
|
+
return (0, earlier_messages_1.isAsk)(message, index, messages) && !TASK_UPDATE.test(text) && !assistant_task_util_1.AssistantTaskUtil.isRenamedNote(text);
|
|
121
121
|
};
|
|
122
122
|
function lastReply(messages, start) {
|
|
123
123
|
for (let index = messages.length - 1; index >= 0; index--) {
|
|
@@ -150,6 +150,7 @@ function DoubleUserMessage({ message, blocks }) {
|
|
|
150
150
|
const { text, copied, skill } = (0, message_list_1.userWords)(blocks);
|
|
151
151
|
const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({ kind: 'user', message, text: copied });
|
|
152
152
|
return (React.createElement("div", { className: `ta-msg-user ${conversation_scroll_1.ASK_CLASS}`, onContextMenu: onContextMenu },
|
|
153
|
+
React.createElement(message_list_1.UserMarks, { blocks: blocks }),
|
|
153
154
|
skill && React.createElement(message_list_1.SkillUse, { skill: skill }),
|
|
154
155
|
React.createElement(message_list_1.UserSaid, { blocks: blocks, text: text, bubble: "ta-msg-bubble", timestamp: message.timestamp }),
|
|
155
156
|
React.createElement(message_footer_1.UserFooter, { message: message, text: copied }),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ClientTool, type SessionState, type SessionStore } from '@celljs/ta-client';
|
|
2
2
|
import { type TaPromptInput, type TaServer, type TaSessionInfo } from '@celljs/ta-protocol';
|
|
3
|
+
import { TaWebExtensions } from '../extension/web-extension-protocol';
|
|
3
4
|
import { TaKeptChats } from '../offline/kept-chats-protocol';
|
|
4
5
|
import { type Settings, TaSettings } from '../settings/settings-protocol';
|
|
5
6
|
import { TaState } from '../state/state-protocol';
|
|
6
7
|
import type { ComposerImage } from '../util/composer';
|
|
7
8
|
import { TaWorkbench } from '../workbench-protocol';
|
|
9
|
+
import { AssistantInitiative } from './assistant-initiative';
|
|
8
10
|
import { type AssistantAsk, type AssistantState, type AssistantTask, TaAssistant } from './assistant-protocol';
|
|
9
11
|
import { AssistantTaskBook } from './assistant-task-book';
|
|
10
12
|
/** What the double is to hear of a task that ended (finished), and when it ended. */
|
|
@@ -18,6 +20,9 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
18
20
|
protected readonly persisted: TaState;
|
|
19
21
|
protected readonly settings: TaSettings;
|
|
20
22
|
protected readonly kept: TaKeptChats;
|
|
23
|
+
protected readonly extensions: TaWebExtensions;
|
|
24
|
+
/** Whether it asks before starting a task, kept with the extension of the user's trust. */
|
|
25
|
+
protected readonly initiative: AssistantInitiative;
|
|
21
26
|
protected current: AssistantState;
|
|
22
27
|
protected assistant?: SessionStore;
|
|
23
28
|
/** Until the conversation is open (and while the computer cannot be reached): it as this device kept it. */
|
|
@@ -13,10 +13,13 @@ exports.TaAssistantImpl = void 0;
|
|
|
13
13
|
const core_1 = require("@celljs/core");
|
|
14
14
|
const ta_client_1 = require("@celljs/ta-client");
|
|
15
15
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
16
|
+
const web_extension_protocol_1 = require("../extension/web-extension-protocol");
|
|
17
|
+
const messages_1 = require("../i18n/messages");
|
|
16
18
|
const kept_chats_protocol_1 = require("../offline/kept-chats-protocol");
|
|
17
19
|
const settings_protocol_1 = require("../settings/settings-protocol");
|
|
18
20
|
const state_protocol_1 = require("../state/state-protocol");
|
|
19
21
|
const workbench_protocol_1 = require("../workbench-protocol");
|
|
22
|
+
const assistant_initiative_1 = require("./assistant-initiative");
|
|
20
23
|
const assistant_protocol_1 = require("./assistant-protocol");
|
|
21
24
|
const assistant_role_1 = require("./assistant-role");
|
|
22
25
|
const assistant_state_1 = require("./assistant-state");
|
|
@@ -27,6 +30,8 @@ const { FILE, TASKS, PROMPT, ASKING } = assistant_state_1.AssistantStates;
|
|
|
27
30
|
const NOTE_SETTLE_MS = 5000;
|
|
28
31
|
let TaAssistantImpl = class TaAssistantImpl {
|
|
29
32
|
constructor() {
|
|
33
|
+
/** Whether it asks before starting a task, kept with the extension of the user's trust. */
|
|
34
|
+
this.initiative = new assistant_initiative_1.AssistantInitiative(() => this.extensions, () => this.settings);
|
|
30
35
|
this.current = { ready: false, tasks: [], asks: [] };
|
|
31
36
|
this.taskStores = new Map();
|
|
32
37
|
this.followAgain = false;
|
|
@@ -62,6 +67,7 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
62
67
|
start() {
|
|
63
68
|
var _a, _b;
|
|
64
69
|
(_a = this.unwatchSettings) !== null && _a !== void 0 ? _a : (this.unwatchSettings = this.settings.subscribe(state => this.settingsChanged(state.settings)));
|
|
70
|
+
this.initiative.start();
|
|
65
71
|
(_b = this.starting) !== null && _b !== void 0 ? _b : (this.starting = this.open().catch(error => {
|
|
66
72
|
this.starting = undefined;
|
|
67
73
|
if (ta_client_1.TaRemoteError.isConnectionLost(error)) {
|
|
@@ -69,7 +75,11 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
69
75
|
setTimeout(() => void this.workbench.connected().then(() => (this.starting || this.assistant ? undefined : this.start()), () => undefined), 1000);
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
// One let into another's Ta without starting conversations there: what they may use is said, not an error of the server.
|
|
79
|
+
const forbidden = ta_protocol_1.TaErrorUtil.code(error) === ta_protocol_1.TaErrorCode.FORBIDDEN;
|
|
80
|
+
this.update({
|
|
81
|
+
error: forbidden ? (0, messages_1.message)(this.settings.state.language, 'ta.assistant.forbidden') : error instanceof Error ? error.message : String(error),
|
|
82
|
+
});
|
|
73
83
|
}));
|
|
74
84
|
return this.starting;
|
|
75
85
|
}
|
|
@@ -358,6 +368,7 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
358
368
|
}
|
|
359
369
|
/** Asking first or not is in the role: the conversation opens again with it, once the double is not at work. */
|
|
360
370
|
settingsChanged(settings) {
|
|
371
|
+
this.initiative.settingsChanged(settings);
|
|
361
372
|
const store = this.assistant;
|
|
362
373
|
if (store && settings.assistantModel && settings.assistantModel !== this.model) {
|
|
363
374
|
void this.applyModel(store.sessionId);
|
|
@@ -513,7 +524,7 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
513
524
|
}
|
|
514
525
|
// Its session closed since (idle, or the service restarted): opened again from its file.
|
|
515
526
|
const store = await this.openTask(id);
|
|
516
|
-
await store.prompt(message, { streamingBehavior: 'steer' });
|
|
527
|
+
await store.prompt(ta_protocol_1.TaMessageSource.mark(message, ta_protocol_1.TaMessageSource.DOUBLE), { streamingBehavior: 'steer' });
|
|
517
528
|
return `Sent to task ${id}.`;
|
|
518
529
|
},
|
|
519
530
|
stop_task: async ({ id }) => {
|
|
@@ -534,8 +545,12 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
534
545
|
throw new Error(`${running} tasks run already, as many as the user lets run at once: wait for one to end (a <task_update> comes), or stop one.`);
|
|
535
546
|
}
|
|
536
547
|
const where = cwd || ((_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) || '.';
|
|
537
|
-
if (confirmTasks
|
|
538
|
-
|
|
548
|
+
if (confirmTasks) {
|
|
549
|
+
const started = await this.ask({ id: `a${++this.asked}`, title, instructions, cwd: where, at: Date.now() });
|
|
550
|
+
this.initiative.record(started ? 'accepted' : 'declined', title);
|
|
551
|
+
if (!started) {
|
|
552
|
+
return `The user did not let task "${title}" start. Ask them what they want instead; do not start it again unasked.`;
|
|
553
|
+
}
|
|
539
554
|
}
|
|
540
555
|
const info = await this.server.openSession({ cwd: where });
|
|
541
556
|
await this.server.setSessionName(info.sessionId, title);
|
|
@@ -546,7 +561,7 @@ let TaAssistantImpl = class TaAssistantImpl {
|
|
|
546
561
|
const task = { id, title, sessionId: info.sessionId, cwd: info.cwd, status: 'running', startedAt: Date.now(), origin: this.sessionFile };
|
|
547
562
|
this.book.add(task);
|
|
548
563
|
const store = await this.follow(task);
|
|
549
|
-
await store.prompt(instructions);
|
|
564
|
+
await store.prompt(ta_protocol_1.TaMessageSource.mark(instructions, ta_protocol_1.TaMessageSource.DOUBLE));
|
|
550
565
|
const { sessionFile } = await this.server.getState(info.sessionId);
|
|
551
566
|
this.book.change(task, { sessionFile });
|
|
552
567
|
return `Started task ${this.book.idOf(task)} "${title}" in ${info.cwd}. A <task_update> comes when it ends.`;
|
|
@@ -675,6 +690,10 @@ __decorate([
|
|
|
675
690
|
(0, core_1.Autowired)(kept_chats_protocol_1.TaKeptChats),
|
|
676
691
|
__metadata("design:type", Object)
|
|
677
692
|
], TaAssistantImpl.prototype, "kept", void 0);
|
|
693
|
+
__decorate([
|
|
694
|
+
(0, core_1.Autowired)({ id: web_extension_protocol_1.TaWebExtensions, detached: true }),
|
|
695
|
+
__metadata("design:type", Object)
|
|
696
|
+
], TaAssistantImpl.prototype, "extensions", void 0);
|
|
678
697
|
exports.TaAssistantImpl = TaAssistantImpl = __decorate([
|
|
679
698
|
(0, core_1.Component)(assistant_protocol_1.TaAssistant)
|
|
680
699
|
], TaAssistantImpl);
|
|
@@ -29,13 +29,15 @@ export interface RailProps {
|
|
|
29
29
|
onSurface(surface: PhoneSurface | undefined): void;
|
|
30
30
|
/** What a held entry does: the double listens, the chats open a new one (entryHold). */
|
|
31
31
|
holds: EntryHolds;
|
|
32
|
+
/** The conversations that wait for the user to decide (ChatAskUtil.count): a count on the entry of the chats. */
|
|
33
|
+
asks?: number;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* The navigation on the left, as the tabs of a phone: the logo; the lists of the sidebar; the pages, and Discover
|
|
35
37
|
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
36
38
|
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
37
39
|
*/
|
|
38
|
-
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }: RailProps): React.JSX.Element;
|
|
40
|
+
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, }: RailProps): React.JSX.Element;
|
|
39
41
|
/** A sidebar view of a web extension, under its title or its own top bar. */
|
|
40
42
|
export declare function SidebarView({ view }: {
|
|
41
43
|
view: WebViewEntry;
|
|
@@ -48,6 +48,7 @@ const use_t_1 = require("../i18n/use-t");
|
|
|
48
48
|
const agent_settings_1 = require("../settings/agent-settings");
|
|
49
49
|
const navigation_1 = require("../settings/navigation");
|
|
50
50
|
const account_menu_1 = require("./account-menu");
|
|
51
|
+
const asks_badge_1 = require("./asks-badge");
|
|
51
52
|
const connection_bar_1 = require("./connection-bar");
|
|
52
53
|
const context_menu_1 = require("./context-menu");
|
|
53
54
|
const dino_1 = require("./dino");
|
|
@@ -86,7 +87,7 @@ function RailItem({ label, active, onClick, onContextMenu, onPointerDown, 'data-
|
|
|
86
87
|
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
87
88
|
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
88
89
|
*/
|
|
89
|
-
function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }) {
|
|
90
|
+
function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, }) {
|
|
90
91
|
const t = (0, use_t_1.useT)();
|
|
91
92
|
const [{ server }] = (0, hooks_1.useWorkbench)();
|
|
92
93
|
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
@@ -106,7 +107,9 @@ function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, on
|
|
|
106
107
|
React.createElement(dino_1.Dino, { size: 26 })),
|
|
107
108
|
React.createElement("div", { className: "ta-rail-items" },
|
|
108
109
|
navigation.home && item(navigation.home, false, true),
|
|
109
|
-
lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held((0, nav_places_1.entryHold)(entry.id, entry.double, holds)) },
|
|
110
|
+
lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held((0, nav_places_1.entryHold)(entry.id, entry.double, holds)) },
|
|
111
|
+
entry.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
|
|
112
|
+
entry.id === '' && !!asks && React.createElement(asks_badge_1.AsksBadge, { count: asks })))),
|
|
110
113
|
(navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
|
|
111
114
|
navigation.nav.map(view => item(view)),
|
|
112
115
|
discover && (React.createElement(RailItem, { label: t('ta.discover'), active: !settingsShown && current === nav_places_1.DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
|