@adecore/agents-react 0.46.3 → 0.48.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/dist/agents/accounts.d.ts +9 -1
- package/dist/agents/accounts.js +31 -7
- package/dist/chat/account-choice.d.ts +5 -4
- package/dist/chat/account-choice.js +47 -39
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +1 -0
- package/dist/chat/logic/scrubber.js +12 -0
- package/dist/chat/logic/timeline-copy.js +2 -0
- package/dist/chat/logic/timeline.d.ts +6 -1
- package/dist/chat/logic/timeline.js +36 -10
- package/dist/chat/preferences.d.ts +2 -2
- package/dist/chat/preferences.js +11 -5
- package/dist/chat/ui/AccountPill.js +9 -6
- package/dist/chat/ui/ChatActivity.d.ts +2 -1
- package/dist/chat/ui/ChatActivity.js +295 -61
- package/dist/chat/ui/Composer.d.ts +2 -1
- package/dist/chat/ui/Composer.js +492 -486
- package/dist/chat/ui/LimitState.js +180 -172
- package/dist/chat/ui/PromptEditor.js +4 -1
- package/dist/chat/ui/ReferenceChip.d.ts +2 -1
- package/dist/chat/ui/ReferenceChip.js +135 -100
- package/dist/chat/ui/UnifiedDiff.js +22 -19
- package/dist/chat/ui/composer/ComposerControls.js +1 -1
- package/dist/chat/ui/composer/ComposerMenu.js +17 -11
- package/dist/chat/ui/composer/chips.d.ts +3 -0
- package/dist/chat/ui/composer/chips.js +14 -10
- package/dist/chat/ui/composer/use-chat-controls.js +70 -67
- package/dist/chat/ui/diff/EditorEditDiff.d.ts +3 -1
- package/dist/chat/ui/diff/EditorEditDiff.js +24 -18
- package/dist/chat/ui/diff/EditorPatchDiff.d.ts +3 -1
- package/dist/chat/ui/diff/EditorPatchDiff.js +4 -2
- package/dist/chat/ui/diff/diff-props.d.ts +2 -0
- package/dist/chat/ui/reference-icons.d.ts +3 -0
- package/dist/chat/ui/reference-icons.js +15 -2
- package/dist/chat/ui/rows/MessageRows.d.ts +6 -1
- package/dist/chat/ui/rows/MessageRows.js +166 -10
- package/dist/chat/ui/rows/RowContainer.js +21 -22
- package/dist/chat/ui/rows/Rows.js +37 -19
- package/dist/chat/ui/rows/WorkflowRow.d.ts +2 -1
- package/dist/chat/ui/rows/WorkflowRow.js +197 -191
- package/dist/chat/ui/rows/row-rhythm.d.ts +1 -0
- package/dist/chat/ui/rows/row-rhythm.js +12 -3
- package/dist/chat/workflow-list.d.ts +12 -0
- package/dist/chat/workflow-list.js +54 -0
- package/dist/host-hooks.d.ts +3 -0
- package/dist/host-hooks.js +8 -0
- package/dist/host.d.ts +11 -1
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +9 -0
- package/dist/locales/en/agent-chat.js +9 -0
- package/dist/locales/en/agent-providers.d.ts +5 -0
- package/dist/locales/en/agent-providers.js +8 -3
- package/dist/locales/nl/agent-chat.d.ts +9 -0
- package/dist/locales/nl/agent-chat.js +9 -0
- package/dist/locales/nl/agent-providers.d.ts +5 -0
- package/dist/locales/nl/agent-providers.js +8 -3
- package/dist/providers/AccountOrderList.d.ts +10 -0
- package/dist/providers/AccountOrderList.js +158 -0
- package/dist/providers/CliDetail.js +55 -61
- package/dist/providers/account-actions.d.ts +1 -0
- package/dist/providers/account-actions.js +39 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/usage/limit-groups.js +6 -1
- package/package.json +8 -8
- package/src/agents/accounts.ts +42 -6
- package/src/chat/account-choice.ts +31 -10
- package/src/chat/index.ts +1 -0
- package/src/chat/logic/scrubber.ts +5 -0
- package/src/chat/logic/timeline-copy.ts +2 -0
- package/src/chat/logic/timeline.ts +33 -2
- package/src/chat/preferences.ts +33 -8
- package/src/chat/ui/AccountPill.tsx +3 -3
- package/src/chat/ui/ChatActivity.tsx +52 -6
- package/src/chat/ui/Composer.tsx +19 -3
- package/src/chat/ui/LimitState.tsx +4 -2
- package/src/chat/ui/PromptEditor.tsx +3 -1
- package/src/chat/ui/ReferenceChip.tsx +15 -5
- package/src/chat/ui/UnifiedDiff.tsx +12 -1
- package/src/chat/ui/composer/ComposerControls.tsx +1 -1
- package/src/chat/ui/composer/ComposerMenu.tsx +4 -2
- package/src/chat/ui/composer/chips.ts +15 -9
- package/src/chat/ui/composer/use-chat-controls.ts +4 -1
- package/src/chat/ui/diff/EditorEditDiff.tsx +9 -4
- package/src/chat/ui/diff/EditorPatchDiff.tsx +5 -1
- package/src/chat/ui/diff/diff-props.ts +3 -0
- package/src/chat/ui/reference-icons.ts +13 -1
- package/src/chat/ui/rows/MessageRows.tsx +35 -0
- package/src/chat/ui/rows/RowContainer.tsx +2 -2
- package/src/chat/ui/rows/Rows.tsx +3 -0
- package/src/chat/ui/rows/WorkflowRow.tsx +9 -4
- package/src/chat/ui/rows/row-rhythm.ts +12 -3
- package/src/chat/workflow-list.ts +65 -0
- package/src/host-hooks.ts +13 -0
- package/src/host.ts +23 -1
- package/src/index.ts +1 -0
- package/src/locales/en/agent-chat.ts +9 -0
- package/src/locales/en/agent-providers.ts +8 -3
- package/src/locales/nl/agent-chat.ts +9 -0
- package/src/locales/nl/agent-providers.ts +8 -3
- package/src/providers/AccountOrderList.tsx +124 -0
- package/src/providers/CliDetail.tsx +33 -28
- package/src/providers/account-actions.ts +30 -0
- package/src/providers/index.ts +11 -1
- package/src/usage/limit-groups.ts +8 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentKind, type ProviderAccount, type ProviderAccounts, type ProviderAccountStatus } from '@adecore/agent-contracts';
|
|
2
2
|
import type { AccentChoice, ChatHost } from '../host.js';
|
|
3
3
|
export declare function accountColor(color: string | undefined, accents: readonly AccentChoice[]): string | undefined;
|
|
4
4
|
export declare const FOLDER_VARIABLES: Partial<Record<AgentKind, string>>;
|
|
@@ -9,6 +9,14 @@ export interface AccountEntry {
|
|
|
9
9
|
isDefault: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function accountsOfKind(accounts: ProviderAccounts | null, kind: AgentKind): AccountEntry[];
|
|
12
|
+
export declare function topAccountEntry(entries: readonly AccountEntry[]): AccountEntry | null;
|
|
13
|
+
export declare function movedIds(ids: readonly string[], id: string, to: number): string[];
|
|
14
|
+
export type AccountRule = Partial<Record<string, {
|
|
15
|
+
default?: string;
|
|
16
|
+
off?: readonly string[];
|
|
17
|
+
}>>;
|
|
18
|
+
export declare function projectOffered(entries: readonly AccountEntry[], rule: AccountRule | null | undefined, kind: AgentKind, current: string | undefined): AccountEntry[];
|
|
19
|
+
export declare function projectDefault(entries: readonly AccountEntry[], rule: AccountRule | null | undefined, kind: AgentKind): string | null;
|
|
12
20
|
export declare function accountName(entry: Pick<AccountEntry, 'id' | 'account' | 'isDefault'>, providerName: string): string;
|
|
13
21
|
export type AccountLogin = 'terminal' | 'chat' | null;
|
|
14
22
|
export declare function accountLoginOf(accounts: ProviderAccounts | null | undefined, kind: AgentKind): AccountLogin;
|
package/dist/agents/accounts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import i18next from 'i18next';
|
|
2
|
+
import { orderedAccountIds } from '@adecore/agent-contracts';
|
|
2
3
|
/*
|
|
3
4
|
* An account wears one of the host's accents, so the app paints from one palette. A color that is none
|
|
4
5
|
* of them (an older name, or one written by hand) reads as undefined, and the dot takes the accent.
|
|
@@ -14,18 +15,41 @@ export const FOLDER_VARIABLES = {
|
|
|
14
15
|
claude: 'CLAUDE_CONFIG_DIR',
|
|
15
16
|
codex: 'CODEX_HOME'
|
|
16
17
|
};
|
|
17
|
-
/* The accounts of one CLI
|
|
18
|
+
/* The accounts of one CLI in the person's order, the one every list and menu shows. */
|
|
18
19
|
export function accountsOfKind(accounts, kind) {
|
|
19
20
|
if (accounts === null) {
|
|
20
21
|
return [];
|
|
21
22
|
}
|
|
22
23
|
const statuses = new Map(accounts.statuses.map(status => [status.id, status]));
|
|
23
|
-
return
|
|
24
|
-
id
|
|
25
|
-
account
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return orderedAccountIds(accounts.accounts, kind).flatMap(id => {
|
|
25
|
+
const account = accounts.accounts[id];
|
|
26
|
+
return account === undefined ? [] : [{
|
|
27
|
+
id,
|
|
28
|
+
account,
|
|
29
|
+
status: statuses.get(id) ?? null,
|
|
30
|
+
isDefault: id === kind
|
|
31
|
+
}];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/* The account a new chat of this CLI starts on when nothing names one, as the machine decides it. */
|
|
35
|
+
export function topAccountEntry(entries) {
|
|
36
|
+
return entries.find(entry => entry.account.enabled !== false) ?? null;
|
|
37
|
+
}
|
|
38
|
+
/* The ids of an order with one moved to another place, clamped to the ends. */
|
|
39
|
+
export function movedIds(ids, id, to) {
|
|
40
|
+
const rest = ids.filter(candidate => candidate !== id);
|
|
41
|
+
const place = Math.max(0, Math.min(to, rest.length));
|
|
42
|
+
return [...rest.slice(0, place), id, ...rest.slice(place)];
|
|
43
|
+
}
|
|
44
|
+
/* The accounts a project offers, as `offeredAccounts` gives them; the one in use stays even when the project turned it off. */
|
|
45
|
+
export function projectOffered(entries, rule, kind, current) {
|
|
46
|
+
const off = rule?.[kind]?.off ?? [];
|
|
47
|
+
return entries.filter(entry => !off.includes(entry.id) || entry.id === current);
|
|
48
|
+
}
|
|
49
|
+
/* The project's own default account of a CLI, while the machine still has it and it is on. */
|
|
50
|
+
export function projectDefault(entries, rule, kind) {
|
|
51
|
+
const id = rule?.[kind]?.default;
|
|
52
|
+
return entries.some(entry => entry.id === id && entry.account.enabled !== false) ? id ?? null : null;
|
|
29
53
|
}
|
|
30
54
|
/* A default account nobody named goes by its CLI's name. */
|
|
31
55
|
export function accountName(entry, providerName) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentKind, ProviderAccounts } from '@adecore/agent-contracts';
|
|
2
|
-
import { type AccountEntry } from '../agents/accounts.js';
|
|
2
|
+
import { type AccountEntry, type AccountRule } from '../agents/accounts.js';
|
|
3
3
|
import { type ProviderAccountsRow } from '../state/provider-accounts.js';
|
|
4
4
|
export interface AccountChoice {
|
|
5
5
|
accounts: ProviderAccounts;
|
|
@@ -9,7 +9,7 @@ export interface AccountChoice {
|
|
|
9
9
|
providerName: string;
|
|
10
10
|
nameOf(entry: AccountEntry): string;
|
|
11
11
|
}
|
|
12
|
-
export declare function useAccountChoice(kind: AgentKind | null, account: string | undefined): AccountChoice | null;
|
|
12
|
+
export declare function useAccountChoice(kind: AgentKind | null, account: string | undefined, chatId: string): AccountChoice | null;
|
|
13
13
|
export type NewAccountChoice = {
|
|
14
14
|
status: 'loading';
|
|
15
15
|
} | {
|
|
@@ -17,8 +17,9 @@ export type NewAccountChoice = {
|
|
|
17
17
|
} | {
|
|
18
18
|
status: 'ready';
|
|
19
19
|
offered: AccountEntry[];
|
|
20
|
+
projectDefault: string | null;
|
|
20
21
|
providerName: string;
|
|
21
22
|
nameOf(entry: AccountEntry): string;
|
|
22
23
|
};
|
|
23
|
-
export declare function newAccountChoiceOf(row: ProviderAccountsRow, kind: AgentKind | null, providerName: string): NewAccountChoice;
|
|
24
|
-
export declare function useNewAccountChoice(kind: AgentKind | null): NewAccountChoice;
|
|
24
|
+
export declare function newAccountChoiceOf(row: ProviderAccountsRow, kind: AgentKind | null, providerName: string, rule?: AccountRule | null): NewAccountChoice;
|
|
25
|
+
export declare function useNewAccountChoice(kind: AgentKind | null, rule?: AccountRule | null): NewAccountChoice;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { accountName, accountsOfKind, hasAccountChoice, offeredAccounts } from '../agents/accounts.js';
|
|
2
|
+
import { accountName, accountsOfKind, hasAccountChoice, offeredAccounts, projectDefault, projectOffered } from '../agents/accounts.js';
|
|
3
|
+
import { useHostAccountRule } from '../host-hooks.js';
|
|
4
|
+
import { useChatScope } from '../scope.js';
|
|
3
5
|
import { useProviderAccounts } from '../state/provider-accounts.js';
|
|
4
6
|
import { useProviders } from '../state/providers.js';
|
|
5
7
|
/*
|
|
6
8
|
* The accounts of a chat's CLI on the machine in scope and the one the chat runs under, or null while
|
|
7
9
|
* the CLI has fewer than two accounts that are on: with one there is nothing to choose or tell apart.
|
|
8
10
|
*/
|
|
9
|
-
export function useAccountChoice(kind, account) {
|
|
10
|
-
const $ = _c(
|
|
11
|
+
export function useAccountChoice(kind, account, chatId) {
|
|
12
|
+
const $ = _c(18);
|
|
13
|
+
const scope = useChatScope();
|
|
14
|
+
const rule = useHostAccountRule(scope.id, chatId);
|
|
11
15
|
const accounts = useProviderAccounts(_temp);
|
|
12
16
|
const providerName = useProviders(row_0 => row_0.providers.find(entry => entry.kind === kind)?.name) ?? kind ?? "";
|
|
13
17
|
if (kind === null || accounts === null) {
|
|
@@ -18,7 +22,7 @@ export function useAccountChoice(kind, account) {
|
|
|
18
22
|
let t2;
|
|
19
23
|
let t3;
|
|
20
24
|
let t4;
|
|
21
|
-
if ($[0] !== account || $[1] !== accounts || $[2] !== kind) {
|
|
25
|
+
if ($[0] !== account || $[1] !== accounts || $[2] !== kind || $[3] !== rule) {
|
|
22
26
|
t4 = Symbol.for("react.early_return_sentinel");
|
|
23
27
|
bb0: {
|
|
24
28
|
const entries = accountsOfKind(accounts, kind);
|
|
@@ -28,38 +32,39 @@ export function useAccountChoice(kind, account) {
|
|
|
28
32
|
}
|
|
29
33
|
const currentId = account ?? kind;
|
|
30
34
|
t0 = accounts;
|
|
31
|
-
t1 = offeredAccounts(entries, currentId);
|
|
35
|
+
t1 = projectOffered(offeredAccounts(entries, currentId), rule, kind, currentId);
|
|
32
36
|
t2 = currentId;
|
|
33
37
|
t3 = entries.find(entry_0 => entry_0.id === currentId) ?? null;
|
|
34
38
|
}
|
|
35
39
|
$[0] = account;
|
|
36
40
|
$[1] = accounts;
|
|
37
41
|
$[2] = kind;
|
|
38
|
-
$[3] =
|
|
39
|
-
$[4] =
|
|
40
|
-
$[5] =
|
|
41
|
-
$[6] =
|
|
42
|
-
$[7] =
|
|
42
|
+
$[3] = rule;
|
|
43
|
+
$[4] = t0;
|
|
44
|
+
$[5] = t1;
|
|
45
|
+
$[6] = t2;
|
|
46
|
+
$[7] = t3;
|
|
47
|
+
$[8] = t4;
|
|
43
48
|
} else {
|
|
44
|
-
t0 = $[
|
|
45
|
-
t1 = $[
|
|
46
|
-
t2 = $[
|
|
47
|
-
t3 = $[
|
|
48
|
-
t4 = $[
|
|
49
|
+
t0 = $[4];
|
|
50
|
+
t1 = $[5];
|
|
51
|
+
t2 = $[6];
|
|
52
|
+
t3 = $[7];
|
|
53
|
+
t4 = $[8];
|
|
49
54
|
}
|
|
50
55
|
if (t4 !== Symbol.for("react.early_return_sentinel")) {
|
|
51
56
|
return t4;
|
|
52
57
|
}
|
|
53
58
|
let t5;
|
|
54
|
-
if ($[
|
|
59
|
+
if ($[9] !== providerName) {
|
|
55
60
|
t5 = entry_1 => accountName(entry_1, providerName);
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
61
|
+
$[9] = providerName;
|
|
62
|
+
$[10] = t5;
|
|
58
63
|
} else {
|
|
59
|
-
t5 = $[
|
|
64
|
+
t5 = $[10];
|
|
60
65
|
}
|
|
61
66
|
let t6;
|
|
62
|
-
if ($[
|
|
67
|
+
if ($[11] !== providerName || $[12] !== t0 || $[13] !== t1 || $[14] !== t2 || $[15] !== t3 || $[16] !== t5) {
|
|
63
68
|
t6 = {
|
|
64
69
|
accounts: t0,
|
|
65
70
|
offered: t1,
|
|
@@ -68,15 +73,15 @@ export function useAccountChoice(kind, account) {
|
|
|
68
73
|
providerName,
|
|
69
74
|
nameOf: t5
|
|
70
75
|
};
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
76
|
+
$[11] = providerName;
|
|
77
|
+
$[12] = t0;
|
|
78
|
+
$[13] = t1;
|
|
79
|
+
$[14] = t2;
|
|
80
|
+
$[15] = t3;
|
|
81
|
+
$[16] = t5;
|
|
82
|
+
$[17] = t6;
|
|
78
83
|
} else {
|
|
79
|
-
t6 = $[
|
|
84
|
+
t6 = $[17];
|
|
80
85
|
}
|
|
81
86
|
return t6;
|
|
82
87
|
}
|
|
@@ -91,7 +96,7 @@ const UNSUPPORTED = {
|
|
|
91
96
|
status: 'unsupported'
|
|
92
97
|
};
|
|
93
98
|
/* `useNewAccountChoice` without React, for its tests. */
|
|
94
|
-
export function newAccountChoiceOf(row, kind, providerName) {
|
|
99
|
+
export function newAccountChoiceOf(row, kind, providerName, rule = null) {
|
|
95
100
|
if (kind === null || !row.loaded) {
|
|
96
101
|
return LOADING;
|
|
97
102
|
}
|
|
@@ -102,27 +107,30 @@ export function newAccountChoiceOf(row, kind, providerName) {
|
|
|
102
107
|
}
|
|
103
108
|
return {
|
|
104
109
|
status: 'ready',
|
|
105
|
-
offered: offeredAccounts(entries, undefined),
|
|
110
|
+
offered: projectOffered(offeredAccounts(entries, undefined), rule, kind, undefined),
|
|
111
|
+
projectDefault: projectDefault(entries, rule, kind),
|
|
106
112
|
providerName,
|
|
107
113
|
nameOf: entry => accountName(entry, providerName)
|
|
108
114
|
};
|
|
109
115
|
}
|
|
110
|
-
/* The accounts a new chat or agent of this CLI may start under on the machine in scope. */
|
|
111
|
-
export function useNewAccountChoice(kind) {
|
|
112
|
-
const $ = _c(
|
|
116
|
+
/* The accounts a new chat or agent of this CLI may start under on the machine in scope, within what the project of that start says. */
|
|
117
|
+
export function useNewAccountChoice(kind, t0) {
|
|
118
|
+
const $ = _c(5);
|
|
119
|
+
const rule = t0 === undefined ? null : t0;
|
|
113
120
|
const row = useProviderAccounts(_temp2);
|
|
114
121
|
const providerName = useProviders(entry_0 => entry_0.providers.find(provider => provider.kind === kind)?.name) ?? kind ?? "";
|
|
115
|
-
let
|
|
116
|
-
if ($[0] !== kind || $[1] !== providerName || $[2] !== row) {
|
|
117
|
-
|
|
122
|
+
let t1;
|
|
123
|
+
if ($[0] !== kind || $[1] !== providerName || $[2] !== row || $[3] !== rule) {
|
|
124
|
+
t1 = newAccountChoiceOf(row, kind, providerName, rule);
|
|
118
125
|
$[0] = kind;
|
|
119
126
|
$[1] = providerName;
|
|
120
127
|
$[2] = row;
|
|
121
|
-
$[3] =
|
|
128
|
+
$[3] = rule;
|
|
129
|
+
$[4] = t1;
|
|
122
130
|
} else {
|
|
123
|
-
|
|
131
|
+
t1 = $[4];
|
|
124
132
|
}
|
|
125
|
-
return
|
|
133
|
+
return t1;
|
|
126
134
|
}
|
|
127
135
|
function _temp2(entry) {
|
|
128
136
|
return entry;
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { type AccountChoice, useAccountChoice, type NewAccountChoice, useNewAcco
|
|
|
2
2
|
export { transportActions, actionsOf, useChatActions } from './actions.js';
|
|
3
3
|
export { type ChatSendExtras, ChatClient } from './chat-client.js';
|
|
4
4
|
export type { ProjectChat, Referable, ReferableKind, Referables } from './chat-references.js';
|
|
5
|
+
export { REFERENCE_ICONS } from './ui/reference-icons.js';
|
|
5
6
|
export { sendFromComposer, type ComposerSend } from './composer-send.js';
|
|
6
7
|
export { stepEffortFromComposer } from './composer-effort.js';
|
|
7
8
|
export type { EffortStep } from './logic/effort.js';
|
package/dist/chat/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { useAccountChoice, useNewAccountChoice } from './account-choice.js';
|
|
3
3
|
export { transportActions, actionsOf, useChatActions } from './actions.js';
|
|
4
4
|
export { ChatClient } from './chat-client.js';
|
|
5
|
+
export { REFERENCE_ICONS } from './ui/reference-icons.js';
|
|
5
6
|
export { sendFromComposer } from './composer-send.js';
|
|
6
7
|
export { stepEffortFromComposer } from './composer-effort.js';
|
|
7
8
|
export { EMPTY_DRAFT, useDrafts, readDraft, writeDraft, offerDraft } from './drafts.js';
|
|
@@ -80,6 +80,18 @@ export function ticksOf(rows, marks = new Map(), earlier = [], bookmarks = []) {
|
|
|
80
80
|
bookmark
|
|
81
81
|
}];
|
|
82
82
|
}
|
|
83
|
+
// A message another node sent stands in for the turn it opened, whose own line it hides.
|
|
84
|
+
if (row.kind === 'message') {
|
|
85
|
+
return [{
|
|
86
|
+
id: row.id,
|
|
87
|
+
rowIndex,
|
|
88
|
+
kind: 'wake',
|
|
89
|
+
text: row.message.text,
|
|
90
|
+
createdAt: row.createdAt,
|
|
91
|
+
turnId: null,
|
|
92
|
+
bookmark
|
|
93
|
+
}];
|
|
94
|
+
}
|
|
83
95
|
// The other turns nobody asked for (a sub-agent that finished, the CLI going on) are no place to return to.
|
|
84
96
|
if (row.kind === 'turn-start' && ((row.turn.taskIds?.length ?? 0) > 0 || (row.turn.messageFrom?.length ?? 0) > 0)) {
|
|
85
97
|
return [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatApprovalItem, ChatAssistantItem, ChatCheckpointDiff, ChatItem, ChatQuestionItem, ChatSubagentItem, ChatThinkingItem, ChatToolItem, ChatTurnItem, ChatUserItem, ChatVisual, ChatWorkflow } from '@adecore/agent-contracts';
|
|
1
|
+
import type { ChatApprovalItem, ChatAssistantItem, ChatCheckpointDiff, ChatItem, ChatNoteMessage, ChatQuestionItem, ChatSubagentItem, ChatThinkingItem, ChatToolItem, ChatTurnItem, ChatUserItem, ChatVisual, ChatWorkflow } from '@adecore/agent-contracts';
|
|
2
2
|
import type { CommandLook, ThreadCard } from '../../host.js';
|
|
3
3
|
export interface SubagentBranch {
|
|
4
4
|
id: string;
|
|
@@ -69,6 +69,11 @@ export type TimelineRow = {
|
|
|
69
69
|
level: 'info' | 'warning' | 'error';
|
|
70
70
|
text: string;
|
|
71
71
|
from?: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'message';
|
|
74
|
+
id: string;
|
|
75
|
+
message: ChatNoteMessage;
|
|
76
|
+
createdAt: number;
|
|
72
77
|
} | {
|
|
73
78
|
kind: 'compaction';
|
|
74
79
|
id: string;
|
|
@@ -396,15 +396,24 @@ function rowsForItems(items, options, children) {
|
|
|
396
396
|
}
|
|
397
397
|
break;
|
|
398
398
|
case 'note':
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
399
|
+
if (item.message !== undefined) {
|
|
400
|
+
rows.push({
|
|
401
|
+
kind: 'message',
|
|
402
|
+
id: item.id,
|
|
403
|
+
message: item.message,
|
|
404
|
+
createdAt: item.createdAt
|
|
405
|
+
});
|
|
406
|
+
} else {
|
|
407
|
+
rows.push({
|
|
408
|
+
kind: 'note',
|
|
409
|
+
id: item.id,
|
|
410
|
+
level: item.level,
|
|
411
|
+
text: item.text,
|
|
412
|
+
...(item.from === undefined ? {} : {
|
|
413
|
+
from: item.from
|
|
414
|
+
})
|
|
415
|
+
});
|
|
416
|
+
}
|
|
408
417
|
break;
|
|
409
418
|
case 'compaction':
|
|
410
419
|
rows.push({
|
|
@@ -528,6 +537,22 @@ function chunksByTurn(items) {
|
|
|
528
537
|
}
|
|
529
538
|
return chunks;
|
|
530
539
|
}
|
|
540
|
+
/* Whether every node whose message opened the turn has that message among the rows right above it. */
|
|
541
|
+
function opensUnderItsMessages(turn, rows) {
|
|
542
|
+
const from = turn.messageFrom ?? [];
|
|
543
|
+
if (from.length === 0) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
const senders = new Set();
|
|
547
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
548
|
+
const row = rows[i];
|
|
549
|
+
if (row.kind !== 'message') {
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
senders.add(row.message.from);
|
|
553
|
+
}
|
|
554
|
+
return from.every(id => senders.has(id));
|
|
555
|
+
}
|
|
531
556
|
/* The whole thread as rows; items without a turn (older records) are shown as they are. */
|
|
532
557
|
export function deriveTimelineRows(items, options) {
|
|
533
558
|
const rows = [];
|
|
@@ -540,7 +565,8 @@ export function deriveTimelineRows(items, options) {
|
|
|
540
565
|
const turnId = chunk.turnId;
|
|
541
566
|
const turn = chunk.items.find(item => item.kind === 'turn');
|
|
542
567
|
const conversation = chunk.items.filter(item => item.kind !== 'turn');
|
|
543
|
-
|
|
568
|
+
// A turn a message opened needs no line of its own when that message stands right above it.
|
|
569
|
+
if (turn?.origin === 'agent' && !opensUnderItsMessages(turn, rows)) {
|
|
544
570
|
// The agent started this one itself, so there is no message of the person to show above it.
|
|
545
571
|
rows.push({
|
|
546
572
|
kind: 'turn-start',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentKind, type ChatPreferencesPayload, type ModelSelection, type ProviderInfo, type ProviderAccounts, type RuntimeMode } from '@adecore/agent-contracts';
|
|
2
2
|
import { type ChatReadingWidth } from './reading-width.js';
|
|
3
3
|
import { type ChatSendKey } from './send-key.js';
|
|
4
4
|
export interface ChatPreferences {
|
|
@@ -20,7 +20,7 @@ export declare function startingSelection(preferences: ChatPreferences, provider
|
|
|
20
20
|
export declare function withSelection(preferences: ChatPreferences, provider: AgentKind, selection: ModelSelection): ChatPreferences;
|
|
21
21
|
export declare function accountFor(preferences: ChatPreferences, scopeId: string, provider: AgentKind, accounts?: ProviderAccounts | null): string | null;
|
|
22
22
|
export declare function withAccount(preferences: ChatPreferences, scopeId: string, provider: AgentKind, account: string | null): ChatPreferences;
|
|
23
|
-
export declare function chatPreferencesPayload(preferences: ChatPreferences, scopeId: string, accounts?: ProviderAccounts | null): ChatPreferencesPayload;
|
|
23
|
+
export declare function chatPreferencesPayload(preferences: ChatPreferences, scopeId: string, accounts?: ProviderAccounts | null, ordered?: boolean): ChatPreferencesPayload;
|
|
24
24
|
export declare const useChatPreferences: import("zustand").UseBoundStore<import("zustand").StoreApi<ChatPreferences>>;
|
|
25
25
|
export declare function readChatPreferences(): ChatPreferences;
|
|
26
26
|
export declare let CHAT_PREFERENCES_KEY: string;
|
package/dist/chat/preferences.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chatStorageKey, chatStorageLegacyKeys, createChatStore, onChatStorageConfiguration } from '../storage.js';
|
|
2
|
+
import { topAccountOf } from '@adecore/agent-contracts';
|
|
2
3
|
import { persistedJson } from './persisted-json.js';
|
|
3
4
|
import { DEFAULT_READING_WIDTH, isChatReadingWidth } from './reading-width.js';
|
|
4
5
|
import { DEFAULT_SEND_KEY, isChatSendKey } from './send-key.js';
|
|
@@ -118,11 +119,16 @@ export function withAccount(preferences, scopeId, provider, account) {
|
|
|
118
119
|
}
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
/*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
/*
|
|
123
|
+
* What a machine starts a chat with when it starts one with no client mounting it; `accounts` as
|
|
124
|
+
* `accountFor` takes them. A machine that keeps an order of the accounts (`ordered`) starts on its top
|
|
125
|
+
* account, which this sends too; an older one still starts on the account picked here.
|
|
126
|
+
*/
|
|
127
|
+
export function chatPreferencesPayload(preferences, scopeId, accounts, ordered = false) {
|
|
128
|
+
const kinds = ordered ? [...new Set(Object.values(accounts?.accounts ?? {}).map(account => account.kind))] : Object.keys(preferences.accountByMachine[scopeId] ?? {});
|
|
129
|
+
const picks = kinds.flatMap(provider => {
|
|
130
|
+
const account = ordered ? accounts ? topAccountOf(accounts.accounts, provider) : null : accountFor(preferences, scopeId, provider, accounts);
|
|
131
|
+
return account === null || ordered && account === provider ? [] : [[provider, account]];
|
|
126
132
|
});
|
|
127
133
|
return {
|
|
128
134
|
runtimeMode: preferences.runtimeMode,
|
|
@@ -9,13 +9,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
9
|
function AccountPillOf(t0) {
|
|
10
10
|
const $ = _c(16);
|
|
11
11
|
const {
|
|
12
|
+
chatId,
|
|
12
13
|
provider,
|
|
13
14
|
account
|
|
14
15
|
} = t0;
|
|
15
16
|
const {
|
|
16
17
|
t
|
|
17
18
|
} = useTranslation("agent-chat");
|
|
18
|
-
const choice = useAccountChoice(provider, account);
|
|
19
|
+
const choice = useAccountChoice(provider, account, chatId);
|
|
19
20
|
if (choice === null) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
@@ -91,7 +92,7 @@ function AccountPillOf(t0) {
|
|
|
91
92
|
}
|
|
92
93
|
/* Which account a chat node runs under, from the status every client gets; only while its CLI has a choice of accounts. */
|
|
93
94
|
export function AccountPill(t0) {
|
|
94
|
-
const $ = _c(
|
|
95
|
+
const $ = _c(10);
|
|
95
96
|
const {
|
|
96
97
|
chatId
|
|
97
98
|
} = t0;
|
|
@@ -119,16 +120,18 @@ export function AccountPill(t0) {
|
|
|
119
120
|
}
|
|
120
121
|
const account = useChats(t2);
|
|
121
122
|
let t3;
|
|
122
|
-
if ($[6] !== account || $[7] !== provider) {
|
|
123
|
+
if ($[6] !== account || $[7] !== chatId || $[8] !== provider) {
|
|
123
124
|
t3 = provider === undefined ? null : /*#__PURE__*/_jsx(AccountPillOf, {
|
|
125
|
+
chatId: chatId,
|
|
124
126
|
provider: provider,
|
|
125
127
|
account: account
|
|
126
128
|
});
|
|
127
129
|
$[6] = account;
|
|
128
|
-
$[7] =
|
|
129
|
-
$[8] =
|
|
130
|
+
$[7] = chatId;
|
|
131
|
+
$[8] = provider;
|
|
132
|
+
$[9] = t3;
|
|
130
133
|
} else {
|
|
131
|
-
t3 = $[
|
|
134
|
+
t3 = $[9];
|
|
132
135
|
}
|
|
133
136
|
return t3;
|
|
134
137
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type StatusWord } from '../../agents/status-look.js';
|
|
2
|
-
export declare function ChatActivity({ chatId }: {
|
|
2
|
+
export declare function ChatActivity({ chatId, workflows: showsWorkflows }: {
|
|
3
3
|
chatId: string;
|
|
4
|
+
workflows?: boolean;
|
|
4
5
|
}): import("react").JSX.Element | null;
|
|
5
6
|
export declare function StatusIcon({ word }: {
|
|
6
7
|
word: StatusWord;
|