@adecore/agents-react 0.54.16 → 0.55.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/dist/agents/AgentModelLabel.d.ts +5 -0
- package/dist/agents/AgentModelLabel.js +32 -7
- package/dist/chat/account-choice.d.ts +1 -0
- package/dist/chat/account-choice.js +13 -4
- package/dist/chat/mentions.d.ts +24 -2
- package/dist/chat/mentions.js +84 -10
- package/dist/chat/subagent-list.d.ts +0 -1
- package/dist/chat/subagent-list.js +1 -9
- package/dist/chat/tag-suggestions.d.ts +22 -0
- package/dist/chat/tag-suggestions.js +71 -0
- package/dist/chat/ui/Composer.js +489 -447
- package/dist/chat/ui/ComposerInput.d.ts +1 -0
- package/dist/chat/ui/ComposerInput.js +9 -1
- package/dist/chat/ui/Markdown.js +41 -25
- package/dist/chat/ui/NamedChip.d.ts +5 -0
- package/dist/chat/ui/NamedChip.js +118 -0
- package/dist/chat/ui/Pickers.d.ts +0 -4
- package/dist/chat/ui/Pickers.js +1 -141
- package/dist/chat/ui/PromptEditor.js +2 -1
- package/dist/chat/ui/ReferenceChip.d.ts +3 -2
- package/dist/chat/ui/ReferenceChip.js +58 -36
- package/dist/chat/ui/RunSettings.d.ts +3 -2
- package/dist/chat/ui/RunSettings.js +386 -361
- package/dist/chat/ui/SubagentInfo.js +98 -114
- package/dist/chat/ui/SubagentTimeline.js +65 -43
- package/dist/chat/ui/Timeline.js +14 -8
- package/dist/chat/ui/chip-clipboard.js +10 -0
- package/dist/chat/ui/composer/ComposerControls.d.ts +6 -1
- package/dist/chat/ui/composer/ComposerControls.js +171 -158
- package/dist/chat/ui/composer/ComposerMenu.js +184 -55
- package/dist/chat/ui/composer/ComposerPlusMenu.d.ts +18 -0
- package/dist/chat/ui/composer/ComposerPlusMenu.js +400 -0
- package/dist/chat/ui/composer/ComposerStatusLine.d.ts +4 -0
- package/dist/chat/ui/composer/ComposerStatusLine.js +239 -0
- package/dist/chat/ui/composer/chips.d.ts +2 -0
- package/dist/chat/ui/composer/chips.js +66 -5
- package/dist/chat/ui/composer/insert.d.ts +1 -0
- package/dist/chat/ui/composer/insert.js +24 -0
- package/dist/chat/ui/composer/use-composer-menus.js +34 -17
- package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -2
- package/dist/chat/ui/composer/use-prompt-menus.js +290 -202
- package/dist/chat/ui/covered-bottom.d.ts +1 -0
- package/dist/chat/ui/covered-bottom.js +6 -0
- package/dist/chat/ui/named-chip-look.d.ts +14 -0
- package/dist/chat/ui/named-chip-look.js +72 -0
- package/dist/chat/ui/rehype-chips.js +13 -2
- package/dist/host-hooks.d.ts +2 -1
- package/dist/host-hooks.js +6 -0
- package/dist/host.d.ts +17 -0
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +14 -2
- package/dist/locales/en/agent-chat.js +16 -4
- package/dist/locales/nl/agent-chat.d.ts +14 -2
- package/dist/locales/nl/agent-chat.js +16 -4
- package/dist/state/chats.d.ts +1 -0
- package/dist/state/chats.js +45 -0
- package/package.json +9 -9
- package/src/agents/AgentModelLabel.tsx +10 -1
- package/src/chat/account-choice.ts +8 -0
- package/src/chat/mentions.ts +110 -13
- package/src/chat/subagent-list.ts +1 -14
- package/src/chat/tag-suggestions.ts +121 -0
- package/src/chat/ui/Composer.tsx +24 -12
- package/src/chat/ui/ComposerInput.tsx +13 -1
- package/src/chat/ui/Markdown.tsx +5 -0
- package/src/chat/ui/NamedChip.tsx +34 -0
- package/src/chat/ui/Pickers.tsx +1 -51
- package/src/chat/ui/PromptEditor.tsx +7 -1
- package/src/chat/ui/ReferenceChip.tsx +15 -4
- package/src/chat/ui/RunSettings.tsx +51 -29
- package/src/chat/ui/SubagentInfo.tsx +17 -17
- package/src/chat/ui/SubagentTimeline.tsx +7 -2
- package/src/chat/ui/Timeline.tsx +11 -5
- package/src/chat/ui/chip-clipboard.ts +8 -1
- package/src/chat/ui/composer/ComposerControls.tsx +24 -17
- package/src/chat/ui/composer/ComposerMenu.tsx +82 -15
- package/src/chat/ui/composer/ComposerPlusMenu.tsx +158 -0
- package/src/chat/ui/composer/ComposerStatusLine.tsx +94 -0
- package/src/chat/ui/composer/chips.ts +78 -7
- package/src/chat/ui/composer/insert.ts +12 -0
- package/src/chat/ui/composer/use-composer-menus.ts +5 -2
- package/src/chat/ui/composer/use-prompt-menus.ts +55 -10
- package/src/chat/ui/covered-bottom.ts +7 -0
- package/src/chat/ui/named-chip-look.ts +64 -0
- package/src/chat/ui/rehype-chips.ts +17 -2
- package/src/host-hooks.ts +11 -1
- package/src/host.ts +29 -0
- package/src/index.ts +2 -0
- package/src/locales/en/agent-chat.ts +16 -4
- package/src/locales/nl/agent-chat.ts +16 -4
- package/src/state/chats.ts +26 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Icon, Popover, Tooltip } from '@adecore/ui';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const ITEM = 'flex h-6 min-w-0 items-center gap-1.5 rounded-md text-xs text-text-muted';
|
|
7
|
+
function ItemFace(t0) {
|
|
8
|
+
const $ = _c(7);
|
|
9
|
+
const {
|
|
10
|
+
item
|
|
11
|
+
} = t0;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== item.icon) {
|
|
14
|
+
t1 = /*#__PURE__*/_jsx(Icon, {
|
|
15
|
+
icon: item.icon,
|
|
16
|
+
size: 14,
|
|
17
|
+
className: "shrink-0 text-text-faint"
|
|
18
|
+
});
|
|
19
|
+
$[0] = item.icon;
|
|
20
|
+
$[1] = t1;
|
|
21
|
+
} else {
|
|
22
|
+
t1 = $[1];
|
|
23
|
+
}
|
|
24
|
+
let t2;
|
|
25
|
+
if ($[2] !== item.label) {
|
|
26
|
+
t2 = /*#__PURE__*/_jsx("span", {
|
|
27
|
+
className: "truncate",
|
|
28
|
+
children: item.label
|
|
29
|
+
});
|
|
30
|
+
$[2] = item.label;
|
|
31
|
+
$[3] = t2;
|
|
32
|
+
} else {
|
|
33
|
+
t2 = $[3];
|
|
34
|
+
}
|
|
35
|
+
let t3;
|
|
36
|
+
if ($[4] !== t1 || $[5] !== t2) {
|
|
37
|
+
t3 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
38
|
+
children: [t1, t2]
|
|
39
|
+
});
|
|
40
|
+
$[4] = t1;
|
|
41
|
+
$[5] = t2;
|
|
42
|
+
$[6] = t3;
|
|
43
|
+
} else {
|
|
44
|
+
t3 = $[6];
|
|
45
|
+
}
|
|
46
|
+
return t3;
|
|
47
|
+
}
|
|
48
|
+
function StatusItem(t0) {
|
|
49
|
+
const $ = _c(18);
|
|
50
|
+
const {
|
|
51
|
+
item
|
|
52
|
+
} = t0;
|
|
53
|
+
if (item.details === undefined || item.details.length === 0) {
|
|
54
|
+
let t1;
|
|
55
|
+
if ($[0] !== item) {
|
|
56
|
+
t1 = /*#__PURE__*/_jsx("span", {
|
|
57
|
+
className: ITEM,
|
|
58
|
+
children: /*#__PURE__*/_jsx(ItemFace, {
|
|
59
|
+
item: item
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
$[0] = item;
|
|
63
|
+
$[1] = t1;
|
|
64
|
+
} else {
|
|
65
|
+
t1 = $[1];
|
|
66
|
+
}
|
|
67
|
+
const face = t1;
|
|
68
|
+
let t2;
|
|
69
|
+
if ($[2] !== face || $[3] !== item.tooltip) {
|
|
70
|
+
t2 = item.tooltip === undefined ? face : /*#__PURE__*/_jsx(Tooltip, {
|
|
71
|
+
label: item.tooltip,
|
|
72
|
+
children: face
|
|
73
|
+
});
|
|
74
|
+
$[2] = face;
|
|
75
|
+
$[3] = item.tooltip;
|
|
76
|
+
$[4] = t2;
|
|
77
|
+
} else {
|
|
78
|
+
t2 = $[4];
|
|
79
|
+
}
|
|
80
|
+
return t2;
|
|
81
|
+
}
|
|
82
|
+
const t1 = item.tooltip ?? item.label;
|
|
83
|
+
let t2;
|
|
84
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
85
|
+
t2 = clsx(ITEM, "-mx-1.5 px-1.5 hover:bg-surface-hover hover:text-text data-[popup-open]:bg-surface-hover data-[popup-open]:text-text");
|
|
86
|
+
$[5] = t2;
|
|
87
|
+
} else {
|
|
88
|
+
t2 = $[5];
|
|
89
|
+
}
|
|
90
|
+
let t3;
|
|
91
|
+
if ($[6] !== item) {
|
|
92
|
+
t3 = /*#__PURE__*/_jsx(Popover.Trigger, {
|
|
93
|
+
className: t2,
|
|
94
|
+
children: /*#__PURE__*/_jsx(ItemFace, {
|
|
95
|
+
item: item
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
$[6] = item;
|
|
99
|
+
$[7] = t3;
|
|
100
|
+
} else {
|
|
101
|
+
t3 = $[7];
|
|
102
|
+
}
|
|
103
|
+
let t4;
|
|
104
|
+
if ($[8] !== t1 || $[9] !== t3) {
|
|
105
|
+
t4 = /*#__PURE__*/_jsx(Tooltip, {
|
|
106
|
+
label: t1,
|
|
107
|
+
children: t3
|
|
108
|
+
});
|
|
109
|
+
$[8] = t1;
|
|
110
|
+
$[9] = t3;
|
|
111
|
+
$[10] = t4;
|
|
112
|
+
} else {
|
|
113
|
+
t4 = $[10];
|
|
114
|
+
}
|
|
115
|
+
let t5;
|
|
116
|
+
if ($[11] !== item.details) {
|
|
117
|
+
t5 = item.details.map(_temp);
|
|
118
|
+
$[11] = item.details;
|
|
119
|
+
$[12] = t5;
|
|
120
|
+
} else {
|
|
121
|
+
t5 = $[12];
|
|
122
|
+
}
|
|
123
|
+
let t6;
|
|
124
|
+
if ($[13] !== t5) {
|
|
125
|
+
t6 = /*#__PURE__*/_jsx(Popover.Popup, {
|
|
126
|
+
side: "top",
|
|
127
|
+
className: "max-w-120 min-w-56 p-1",
|
|
128
|
+
children: t5
|
|
129
|
+
});
|
|
130
|
+
$[13] = t5;
|
|
131
|
+
$[14] = t6;
|
|
132
|
+
} else {
|
|
133
|
+
t6 = $[14];
|
|
134
|
+
}
|
|
135
|
+
let t7;
|
|
136
|
+
if ($[15] !== t4 || $[16] !== t6) {
|
|
137
|
+
t7 = /*#__PURE__*/_jsxs(Popover.Root, {
|
|
138
|
+
children: [t4, t6]
|
|
139
|
+
});
|
|
140
|
+
$[15] = t4;
|
|
141
|
+
$[16] = t6;
|
|
142
|
+
$[17] = t7;
|
|
143
|
+
} else {
|
|
144
|
+
t7 = $[17];
|
|
145
|
+
}
|
|
146
|
+
return t7;
|
|
147
|
+
}
|
|
148
|
+
/* The line under the card with the app's own items, such as the branch a chat works on. Without items there is no line. */
|
|
149
|
+
function _temp(detail, i) {
|
|
150
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
151
|
+
className: clsx("flex items-start gap-2.5 px-2.5 py-1.5 text-sm", detail.muted ? "text-text-muted" : "text-text"),
|
|
152
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
153
|
+
className: "grid h-lh shrink-0 place-items-center",
|
|
154
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
155
|
+
icon: detail.icon,
|
|
156
|
+
size: 14,
|
|
157
|
+
className: "text-text-faint"
|
|
158
|
+
})
|
|
159
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
160
|
+
className: "flex min-w-0 grow flex-col",
|
|
161
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
162
|
+
className: clsx("break-words", detail.mono && "font-mono"),
|
|
163
|
+
children: detail.label
|
|
164
|
+
}), detail.detail !== undefined && /*#__PURE__*/_jsx("span", {
|
|
165
|
+
className: "font-mono text-xs break-all text-text-faint",
|
|
166
|
+
children: detail.detail
|
|
167
|
+
})]
|
|
168
|
+
}), detail.hint !== undefined && /*#__PURE__*/_jsx("span", {
|
|
169
|
+
className: "shrink-0 pl-3 text-xs/[inherit] text-text-faint",
|
|
170
|
+
children: detail.hint
|
|
171
|
+
})]
|
|
172
|
+
}, i);
|
|
173
|
+
}
|
|
174
|
+
export function ComposerStatusLine(t0) {
|
|
175
|
+
const $ = _c(6);
|
|
176
|
+
const {
|
|
177
|
+
items
|
|
178
|
+
} = t0;
|
|
179
|
+
const {
|
|
180
|
+
t
|
|
181
|
+
} = useTranslation("agent-chat");
|
|
182
|
+
if (items.length === 0) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
let t1;
|
|
186
|
+
if ($[0] !== items || $[1] !== t) {
|
|
187
|
+
const start = items.filter(_temp2);
|
|
188
|
+
const end = items.filter(_temp3);
|
|
189
|
+
let t2;
|
|
190
|
+
if ($[3] !== t) {
|
|
191
|
+
t2 = t("composer.status.label");
|
|
192
|
+
$[3] = t;
|
|
193
|
+
$[4] = t2;
|
|
194
|
+
} else {
|
|
195
|
+
t2 = $[4];
|
|
196
|
+
}
|
|
197
|
+
let t3;
|
|
198
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
199
|
+
t3 = /*#__PURE__*/_jsx("span", {
|
|
200
|
+
"aria-hidden": "true",
|
|
201
|
+
className: "pointer-events-none absolute -top-8 bottom-0 -inset-x-3 -z-10 bg-[linear-gradient(to_bottom,transparent,var(--surface)_--spacing(4))]"
|
|
202
|
+
});
|
|
203
|
+
$[5] = t3;
|
|
204
|
+
} else {
|
|
205
|
+
t3 = $[5];
|
|
206
|
+
}
|
|
207
|
+
t1 = /*#__PURE__*/_jsxs("div", {
|
|
208
|
+
role: "group",
|
|
209
|
+
"aria-label": t2,
|
|
210
|
+
className: "pointer-events-auto relative isolate -mb-1 flex min-w-0 items-center gap-3 pt-1.5 pr-5 pl-[calc(--spacing(5)+1px)] @max-md/composer-area:pl-[calc(--spacing(3.5)+1px)]",
|
|
211
|
+
children: [t3, start.map(_temp4), end.length > 0 && /*#__PURE__*/_jsx("span", {
|
|
212
|
+
className: "ml-auto flex min-w-0 items-center gap-3",
|
|
213
|
+
children: end.map(_temp5)
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
216
|
+
$[0] = items;
|
|
217
|
+
$[1] = t;
|
|
218
|
+
$[2] = t1;
|
|
219
|
+
} else {
|
|
220
|
+
t1 = $[2];
|
|
221
|
+
}
|
|
222
|
+
return t1;
|
|
223
|
+
}
|
|
224
|
+
function _temp5(item_2) {
|
|
225
|
+
return /*#__PURE__*/_jsx(StatusItem, {
|
|
226
|
+
item: item_2
|
|
227
|
+
}, item_2.id);
|
|
228
|
+
}
|
|
229
|
+
function _temp4(item_1) {
|
|
230
|
+
return /*#__PURE__*/_jsx(StatusItem, {
|
|
231
|
+
item: item_1
|
|
232
|
+
}, item_1.id);
|
|
233
|
+
}
|
|
234
|
+
function _temp3(item_0) {
|
|
235
|
+
return item_0.side === "end";
|
|
236
|
+
}
|
|
237
|
+
function _temp2(item) {
|
|
238
|
+
return item.side !== "end";
|
|
239
|
+
}
|
|
@@ -3,6 +3,7 @@ import { type ComponentType } from 'react';
|
|
|
3
3
|
import type { ReferenceIconProps } from '../../../host.js';
|
|
4
4
|
import type { ReferableKind, ReferenceStep } from '../../chat-references.js';
|
|
5
5
|
import { type ReferenceToken } from '../../mentions.js';
|
|
6
|
+
import type { NamedChipLookup } from '../named-chip-look.js';
|
|
6
7
|
export interface ChipChoices {
|
|
7
8
|
mentions: string[];
|
|
8
9
|
skills: string[];
|
|
@@ -11,5 +12,6 @@ export interface ChipChoices {
|
|
|
11
12
|
trail?: readonly ReferenceStep[];
|
|
12
13
|
}>;
|
|
13
14
|
referenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
15
|
+
named?: NamedChipLookup | null;
|
|
14
16
|
}
|
|
15
17
|
export declare function chipDecorations(value: ChipChoices): Extension;
|
|
@@ -3,7 +3,8 @@ import { Facet, StateField } from '@codemirror/state';
|
|
|
3
3
|
import { Decoration, EditorView, WidgetType } from '@codemirror/view';
|
|
4
4
|
import { createElement, Fragment } from 'react';
|
|
5
5
|
import { createRoot } from 'react-dom/client';
|
|
6
|
-
import {
|
|
6
|
+
import { CliMark } from '../../../agents/AgentModelLabel.js';
|
|
7
|
+
import { chipRanges, withNamedChips } from '../../mentions.js';
|
|
7
8
|
import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips.js';
|
|
8
9
|
import { referenceGlyph } from '../reference-icons.js';
|
|
9
10
|
import { ReferenceTrail } from '../ReferenceTrail.js';
|
|
@@ -70,17 +71,74 @@ class ReferenceIcon extends WidgetType {
|
|
|
70
71
|
queueMicrotask(() => root?.unmount());
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
/*
|
|
75
|
+
* A model or an account in place of its whole token: the CLI's mark in the color of the account it runs
|
|
76
|
+
* on, and the name the machine knows it by. The token is one atom, so the caret steps over it whole.
|
|
77
|
+
*/
|
|
78
|
+
class NamedChipWidget extends WidgetType {
|
|
79
|
+
cli;
|
|
80
|
+
look;
|
|
81
|
+
constructor(cli, look) {
|
|
82
|
+
super();
|
|
83
|
+
this.cli = cli;
|
|
84
|
+
this.look = look;
|
|
85
|
+
}
|
|
86
|
+
eq(other) {
|
|
87
|
+
return other.cli === this.cli && other.look.label === this.look.label && other.look.color === this.look.color;
|
|
88
|
+
}
|
|
89
|
+
toDOM() {
|
|
90
|
+
const chip = document.createElement('span');
|
|
91
|
+
const mark = document.createElement('span');
|
|
92
|
+
const root = createRoot(mark);
|
|
93
|
+
chip.className = `${REFERENCE_TONE} ${CHIP_IN_EDITOR}`;
|
|
94
|
+
mark.className = TOKEN_ICON_IN_EDITOR;
|
|
95
|
+
if (this.look.color !== undefined) {
|
|
96
|
+
mark.style.color = this.look.color;
|
|
97
|
+
}
|
|
98
|
+
root.render(createElement(CliMark, {
|
|
99
|
+
kind: this.cli,
|
|
100
|
+
size: 12
|
|
101
|
+
}));
|
|
102
|
+
roots.set(chip, root);
|
|
103
|
+
chip.append(mark, this.look.label);
|
|
104
|
+
return chip;
|
|
105
|
+
}
|
|
106
|
+
destroy(dom) {
|
|
107
|
+
const root = roots.get(dom);
|
|
108
|
+
roots.delete(dom);
|
|
109
|
+
queueMicrotask(() => root?.unmount());
|
|
110
|
+
}
|
|
111
|
+
}
|
|
73
112
|
function chipMarks(state) {
|
|
74
113
|
const {
|
|
75
114
|
mentions,
|
|
76
115
|
skills,
|
|
77
116
|
references = [],
|
|
78
|
-
referenceIcon = null
|
|
117
|
+
referenceIcon = null,
|
|
118
|
+
named = null
|
|
79
119
|
} = state.facet(choices);
|
|
80
120
|
const tokens = new Map(references.map(token => [token.id, token]));
|
|
81
121
|
const marks = [];
|
|
122
|
+
const atoms = [];
|
|
123
|
+
const text = state.doc.toString();
|
|
124
|
+
const code = codeRanges(state);
|
|
82
125
|
// `@a.ts` in backticks is code, not a mention.
|
|
83
|
-
for (const range of chipRanges(
|
|
126
|
+
for (const range of withNamedChips(text, chipRanges(text, mentions, skills, code, references), code)) {
|
|
127
|
+
if (range.kind === 'model' || range.kind === 'account') {
|
|
128
|
+
const slash = range.value.indexOf('/');
|
|
129
|
+
const cli = range.value.slice(0, slash);
|
|
130
|
+
const id = range.value.slice(slash + 1);
|
|
131
|
+
const look = named?.(range.kind, cli, id) ?? {
|
|
132
|
+
label: id,
|
|
133
|
+
color: undefined
|
|
134
|
+
};
|
|
135
|
+
const atom = Decoration.replace({
|
|
136
|
+
widget: new NamedChipWidget(cli, look)
|
|
137
|
+
}).range(range.from, range.to);
|
|
138
|
+
marks.push(atom);
|
|
139
|
+
atoms.push(atom);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
84
142
|
if (range.kind !== 'reference') {
|
|
85
143
|
marks.push((range.kind === 'skill' ? skillMark : mentionMark).range(range.from, range.to));
|
|
86
144
|
continue;
|
|
@@ -93,13 +151,16 @@ function chipMarks(state) {
|
|
|
93
151
|
}).range(range.from, range.from + 1));
|
|
94
152
|
}
|
|
95
153
|
}
|
|
96
|
-
return
|
|
154
|
+
return {
|
|
155
|
+
marks: Decoration.set(marks, true),
|
|
156
|
+
atoms: Decoration.set(atoms, true)
|
|
157
|
+
};
|
|
97
158
|
}
|
|
98
159
|
const chipField = StateField.define({
|
|
99
160
|
create: chipMarks,
|
|
100
161
|
// The parser finishes a long text after the edit that asked for it, and a code span it finds then unmakes a chip.
|
|
101
162
|
update: (marks, tr) => tr.docChanged || tr.startState.facet(choices) !== tr.state.facet(choices) || syntaxTree(tr.startState) !== syntaxTree(tr.state) ? chipMarks(tr.state) : marks,
|
|
102
|
-
provide: field => EditorView.decorations.from(field)
|
|
163
|
+
provide: field => [EditorView.decorations.from(field, value => value.marks), EditorView.atomicRanges.of(view => view.state.field(field).atoms)]
|
|
103
164
|
});
|
|
104
165
|
/* Draws the chosen `@path`, `$name` and `#name` tokens as chips; a new `ChipChoices` object is what redraws them. */
|
|
105
166
|
export function chipDecorations(value) {
|
|
@@ -30,4 +30,28 @@ export function insertAtSelection(state, text) {
|
|
|
30
30
|
scrollIntoView: true,
|
|
31
31
|
userEvent: 'input'
|
|
32
32
|
};
|
|
33
|
+
}
|
|
34
|
+
/* A sigil typed at the caret, so the picker it opens reads what follows it: a word after it is pushed a space away. */
|
|
35
|
+
export function insertSigil(state, sigil) {
|
|
36
|
+
const {
|
|
37
|
+
from,
|
|
38
|
+
to
|
|
39
|
+
} = state.selection.main;
|
|
40
|
+
const before = state.doc.sliceString(Math.max(0, from - 1), from);
|
|
41
|
+
const after = state.doc.sliceString(to, to + 1);
|
|
42
|
+
const lead = before !== '' && !isSpace(before) ? ' ' : '';
|
|
43
|
+
const trail = after !== '' && !isSpace(after) ? ' ' : '';
|
|
44
|
+
const caret = from + lead.length + sigil.length;
|
|
45
|
+
return {
|
|
46
|
+
changes: {
|
|
47
|
+
from,
|
|
48
|
+
to,
|
|
49
|
+
insert: `${lead}${sigil}${trail}`
|
|
50
|
+
},
|
|
51
|
+
selection: {
|
|
52
|
+
anchor: caret
|
|
53
|
+
},
|
|
54
|
+
scrollIntoView: true,
|
|
55
|
+
userEvent: 'input'
|
|
56
|
+
};
|
|
33
57
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { useHostReferables } from '../../../host-hooks.js';
|
|
4
|
+
import { useHostAccountRule, useHostReferables } from '../../../host-hooks.js';
|
|
5
5
|
import { useChatScope } from '../../../scope.js';
|
|
6
6
|
import { usePromptMenus } from './use-prompt-menus.js';
|
|
7
7
|
// Commands the composer handles itself; the CLI's own ones are sent through as text.
|
|
8
8
|
export const LOCAL_COMMANDS = ['model', 'compact', 'clear'];
|
|
9
9
|
/* The pickers over a chat's composer, fed by what the chat's CLI has: its skills, its commands and its folder. */
|
|
10
10
|
export function useComposerMenus(t0) {
|
|
11
|
-
const $ = _c(
|
|
11
|
+
const $ = _c(27);
|
|
12
12
|
const {
|
|
13
13
|
chatId,
|
|
14
14
|
info,
|
|
@@ -22,6 +22,7 @@ export function useComposerMenus(t0) {
|
|
|
22
22
|
} = useTranslation("agent-chat");
|
|
23
23
|
const scope = useChatScope();
|
|
24
24
|
const referables = useHostReferables(scope.id, chatId);
|
|
25
|
+
const accountRule = useHostAccountRule(scope.id, chatId);
|
|
25
26
|
let t1;
|
|
26
27
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
27
28
|
t1 = [];
|
|
@@ -73,8 +74,20 @@ export function useComposerMenus(t0) {
|
|
|
73
74
|
t7 = $[10];
|
|
74
75
|
}
|
|
75
76
|
let t8;
|
|
76
|
-
if ($[11] !==
|
|
77
|
+
if ($[11] !== info.account || $[12] !== info.provider) {
|
|
77
78
|
t8 = {
|
|
79
|
+
provider: info.provider,
|
|
80
|
+
account: info.account
|
|
81
|
+
};
|
|
82
|
+
$[11] = info.account;
|
|
83
|
+
$[12] = info.provider;
|
|
84
|
+
$[13] = t8;
|
|
85
|
+
} else {
|
|
86
|
+
t8 = $[13];
|
|
87
|
+
}
|
|
88
|
+
let t9;
|
|
89
|
+
if ($[14] !== accountRule || $[15] !== chatId || $[16] !== draft || $[17] !== info.slashCommands || $[18] !== inputRef || $[19] !== providerName || $[20] !== referables || $[21] !== skills || $[22] !== t4 || $[23] !== t6 || $[24] !== t7 || $[25] !== t8) {
|
|
90
|
+
t9 = {
|
|
78
91
|
draft,
|
|
79
92
|
inputRef,
|
|
80
93
|
cwd: t4,
|
|
@@ -85,22 +98,26 @@ export function useComposerMenus(t0) {
|
|
|
85
98
|
providerName,
|
|
86
99
|
referables,
|
|
87
100
|
ownId: chatId,
|
|
88
|
-
label: t7
|
|
101
|
+
label: t7,
|
|
102
|
+
accountRule,
|
|
103
|
+
home: t8
|
|
89
104
|
};
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
105
|
+
$[14] = accountRule;
|
|
106
|
+
$[15] = chatId;
|
|
107
|
+
$[16] = draft;
|
|
108
|
+
$[17] = info.slashCommands;
|
|
109
|
+
$[18] = inputRef;
|
|
110
|
+
$[19] = providerName;
|
|
111
|
+
$[20] = referables;
|
|
112
|
+
$[21] = skills;
|
|
113
|
+
$[22] = t4;
|
|
114
|
+
$[23] = t6;
|
|
115
|
+
$[24] = t7;
|
|
116
|
+
$[25] = t8;
|
|
117
|
+
$[26] = t9;
|
|
101
118
|
} else {
|
|
102
|
-
|
|
119
|
+
t9 = $[26];
|
|
103
120
|
}
|
|
104
|
-
return usePromptMenus(
|
|
121
|
+
return usePromptMenus(t9);
|
|
105
122
|
}
|
|
106
123
|
function _temp() {}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ChatSkill } from '@adecore/agent-contracts';
|
|
2
2
|
import type { EditorState } from '@codemirror/state';
|
|
3
3
|
import { type Dispatch, type RefObject, type SetStateAction } from 'react';
|
|
4
|
+
import type { AccountRule } from '../../../agents/accounts.js';
|
|
4
5
|
import { type Referable, type Referables } from '../../chat-references.js';
|
|
5
6
|
import type { ChatDraft } from '../../drafts.js';
|
|
6
|
-
import { type MentionQuery, type TextRange } from '../../mentions.js';
|
|
7
|
+
import { type MentionQuery, type NamedPick, type TextRange } from '../../mentions.js';
|
|
7
8
|
import type { ComposerInputHandle } from '../ComposerInput.js';
|
|
9
|
+
import { type NamedChipHome } from '../named-chip-look.js';
|
|
8
10
|
export type PromptDraft = Pick<ChatDraft, 'text' | 'mentions' | 'skills' | 'chats' | 'references' | 'referenceNames'>;
|
|
9
11
|
export interface PromptDraftBox<D extends PromptDraft> {
|
|
10
12
|
draft: D;
|
|
@@ -30,8 +32,10 @@ export interface PromptMenusInput<D extends PromptDraft> {
|
|
|
30
32
|
referables: Referables;
|
|
31
33
|
ownId?: string;
|
|
32
34
|
label: string;
|
|
35
|
+
accountRule?: AccountRule | null;
|
|
36
|
+
home?: NamedChipHome | null;
|
|
33
37
|
}
|
|
34
|
-
export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft, setDraft, setText }, inputRef, cwd, skills, slashCommands, localCommands, goals, providerName, referables, ownId, label }: PromptMenusInput<D>): {
|
|
38
|
+
export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft, setDraft, setText }, inputRef, cwd, skills, slashCommands, localCommands, goals, providerName, referables, ownId, label, accountRule, home }: PromptMenusInput<D>): {
|
|
35
39
|
listId: string;
|
|
36
40
|
activeIndex: number;
|
|
37
41
|
inputAria: Record<string, string>;
|
|
@@ -52,6 +56,9 @@ export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft,
|
|
|
52
56
|
mentionMenuOpen: boolean;
|
|
53
57
|
mentionCount: number;
|
|
54
58
|
files: string[];
|
|
59
|
+
modelMatches: import("../../tag-suggestions.js").ModelSuggestion[];
|
|
60
|
+
accountMatches: import("../../tag-suggestions.js").AccountSuggestion[];
|
|
61
|
+
namedLook: import("../named-chip-look.js").NamedChipLookup;
|
|
55
62
|
referenceMenuOpen: boolean;
|
|
56
63
|
referenceMatches: Referable[];
|
|
57
64
|
referables: Referables;
|
|
@@ -65,6 +72,7 @@ export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft,
|
|
|
65
72
|
trackTriggers: (value: string, selection: TextRange, state: EditorState) => void;
|
|
66
73
|
close: () => void;
|
|
67
74
|
chooseMention: (path: string) => void;
|
|
75
|
+
chooseNamed: (pick: NamedPick) => void;
|
|
68
76
|
chooseMentionAt: (index: number) => void;
|
|
69
77
|
chooseReference: (item: Referable) => void;
|
|
70
78
|
chooseReferenceAt: (index: number) => void;
|