@adecore/agents-react 0.67.1 → 0.69.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/AgentIcon.d.ts +7 -0
- package/dist/agents/AgentIcon.js +70 -31
- package/dist/chat/logic/timeline.d.ts +2 -0
- package/dist/chat/logic/timeline.js +47 -0
- package/dist/chat/subagent-list.d.ts +1 -2
- package/dist/chat/ui/Composer.js +491 -447
- package/dist/chat/ui/Markdown.d.ts +1 -1
- package/dist/chat/ui/Markdown.js +277 -203
- package/dist/chat/ui/PromptEditor.d.ts +3 -1
- package/dist/chat/ui/PromptEditor.js +4 -1
- package/dist/chat/ui/Timeline.js +5 -4
- package/dist/chat/ui/composer/ComposerMenu.js +22 -12
- package/dist/chat/ui/composer/chips.d.ts +2 -1
- package/dist/chat/ui/composer/chips.js +44 -1
- package/dist/chat/ui/composer/key-handler.d.ts +2 -0
- package/dist/chat/ui/composer/key-handler.js +12 -2
- package/dist/chat/ui/composer/placeholder.d.ts +2 -1
- package/dist/chat/ui/composer/placeholder.js +31 -10
- package/dist/chat/ui/composer/use-composer-menus.js +49 -39
- package/dist/chat/ui/composer/use-prompt-menus.d.ts +10 -7
- package/dist/chat/ui/composer/use-prompt-menus.js +183 -157
- package/dist/chat/ui/composer/use-prompt-suggestion.d.ts +16 -0
- package/dist/chat/ui/composer/use-prompt-suggestion.js +55 -0
- package/dist/chat/ui/index.d.ts +1 -1
- package/dist/chat/ui/index.js +1 -1
- package/dist/chat/ui/markdown-cache.d.ts +4 -0
- package/dist/chat/ui/markdown-cache.js +47 -0
- package/dist/chat/ui/reference-lookup.d.ts +2 -1
- package/dist/chat/ui/reference-lookup.js +1 -1
- package/dist/chat/ui/rows/SubagentRow.js +26 -24
- package/dist/chat/ui/rows/TaskRow.d.ts +11 -1
- package/dist/chat/ui/rows/TaskRow.js +281 -197
- package/dist/chat/ui/thread-references.js +12 -9
- package/dist/chat-client.d.ts +3 -1
- package/dist/chat-client.js +82 -30
- package/dist/chat-sink.d.ts +1 -0
- package/dist/host/host-hooks.d.ts +4 -1
- package/dist/host/host-hooks.js +11 -0
- package/dist/host/host.d.ts +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/locales/en/agent-chat.d.ts +1 -0
- package/dist/locales/en/agent-chat.js +2 -1
- package/dist/locales/nl/agent-chat.d.ts +1 -0
- package/dist/locales/nl/agent-chat.js +2 -1
- package/dist/state/chats.d.ts +2 -0
- package/dist/state/chats.js +21 -5
- package/dist/theme.css +6 -0
- package/package.json +9 -9
- package/src/agents/AgentIcon.tsx +6 -2
- package/src/chat/logic/timeline.ts +63 -0
- package/src/chat/subagent-list.ts +1 -4
- package/src/chat/ui/Composer.tsx +15 -2
- package/src/chat/ui/Markdown.tsx +97 -55
- package/src/chat/ui/PromptEditor.tsx +7 -2
- package/src/chat/ui/Timeline.tsx +17 -14
- package/src/chat/ui/composer/ComposerMenu.tsx +14 -6
- package/src/chat/ui/composer/chips.ts +51 -2
- package/src/chat/ui/composer/key-handler.ts +17 -2
- package/src/chat/ui/composer/placeholder.ts +14 -3
- package/src/chat/ui/composer/use-composer-menus.ts +8 -3
- package/src/chat/ui/composer/use-prompt-menus.ts +33 -4
- package/src/chat/ui/composer/use-prompt-suggestion.ts +36 -0
- package/src/chat/ui/index.ts +1 -1
- package/src/chat/ui/markdown-cache.ts +60 -0
- package/src/chat/ui/reference-lookup.ts +4 -2
- package/src/chat/ui/rows/SubagentRow.tsx +1 -1
- package/src/chat/ui/rows/TaskRow.tsx +54 -9
- package/src/chat/ui/thread-references.ts +4 -2
- package/src/chat-client.ts +79 -22
- package/src/chat-sink.ts +6 -1
- package/src/host/host-hooks.ts +19 -1
- package/src/host/host.ts +41 -0
- package/src/index.ts +3 -0
- package/src/locales/en/agent-chat.ts +2 -1
- package/src/locales/nl/agent-chat.ts +2 -1
- package/src/state/chats.ts +22 -6
- package/src/theme.css +6 -0
|
@@ -19,6 +19,7 @@ export function PromptEditor({
|
|
|
19
19
|
label,
|
|
20
20
|
placeholder,
|
|
21
21
|
skills,
|
|
22
|
+
hostSkills,
|
|
22
23
|
slashCommands = NO_COMMANDS,
|
|
23
24
|
goals = false,
|
|
24
25
|
cwd,
|
|
@@ -56,6 +57,7 @@ export function PromptEditor({
|
|
|
56
57
|
inputRef,
|
|
57
58
|
cwd,
|
|
58
59
|
skills,
|
|
60
|
+
hostSkills,
|
|
59
61
|
slashCommands,
|
|
60
62
|
goals,
|
|
61
63
|
providerName,
|
|
@@ -67,7 +69,8 @@ export function PromptEditor({
|
|
|
67
69
|
skills: value.skills,
|
|
68
70
|
references: menus.referenceChips,
|
|
69
71
|
referenceIcon: host.ReferenceIcon,
|
|
70
|
-
named: menus.namedLook
|
|
72
|
+
named: menus.namedLook,
|
|
73
|
+
hostSkills: menus.hostSkills
|
|
71
74
|
});
|
|
72
75
|
const onKeyDown = e => {
|
|
73
76
|
if (e.isComposing) {
|
package/dist/chat/ui/Timeline.js
CHANGED
|
@@ -17,7 +17,7 @@ import { bookmarkRows } from '../logic/bookmarks.js';
|
|
|
17
17
|
import { forkRefusal } from '../logic/fork.js';
|
|
18
18
|
import { SCRUBBER_MIN_TICKS, STRIP_INSET_PX, STRIP_WIDTH_PX, messagesInView, stepMessage, threadPaddingLeft, STRIP_CLEARANCE_PX, tickOfRow, ticksOf, ticksWithHits, EARLIER_ROW } from '../logic/scrubber.js';
|
|
19
19
|
import { timedRowsOf, withTimedRows } from '../logic/thread-cards.js';
|
|
20
|
-
import { deriveTimelineRows, findSubagentBranch } from '../logic/timeline.js';
|
|
20
|
+
import { createRowKeeper, deriveTimelineRows, findSubagentBranch } from '../logic/timeline.js';
|
|
21
21
|
import { EMPTY_TARGET, readTimelineTarget, revealUiReplyBlock, uiReplyJump, withCurrentText } from '../logic/timeline-target.js';
|
|
22
22
|
import { useChatPreferences } from '../preferences.js';
|
|
23
23
|
import { readingMeasure, readingWidthStyle } from '../reading-width.js';
|
|
@@ -511,11 +511,12 @@ export function Timeline({
|
|
|
511
511
|
});
|
|
512
512
|
}, [scope, chatId, cursor]);
|
|
513
513
|
const hideTools = useHostHidesToolCalls(scopeId, chatId);
|
|
514
|
+
const [keepRows] = useState(createRowKeeper);
|
|
514
515
|
const threadRows = useMemo(() => {
|
|
515
516
|
if (!order || !items) {
|
|
516
517
|
return [];
|
|
517
518
|
}
|
|
518
|
-
return deriveTimelineRows(order.map(id => items[id]), {
|
|
519
|
+
return keepRows(deriveTimelineRows(order.map(id => items[id]), {
|
|
519
520
|
expandedGroups: groups.ids,
|
|
520
521
|
expandedTurns: turns.ids,
|
|
521
522
|
expandedSubagents: subagents.ids,
|
|
@@ -524,8 +525,8 @@ export function Timeline({
|
|
|
524
525
|
commandLooks: host.commandLooks,
|
|
525
526
|
toolLooks: host.toolLooks,
|
|
526
527
|
hideTools
|
|
527
|
-
});
|
|
528
|
-
}, [order, items, groups.ids, turns.ids, subagents.ids, activeTurnId, forkedTurns, host.commandLooks, host.toolLooks, hideTools]);
|
|
528
|
+
}));
|
|
529
|
+
}, [keepRows, order, items, groups.ids, turns.ids, subagents.ids, activeTurnId, forkedTurns, host.commandLooks, host.toolLooks, hideTools]);
|
|
529
530
|
const cards = useHostThreadCards(scopeId, chatId);
|
|
530
531
|
const drawsVisuals = host.visuals !== null;
|
|
531
532
|
// Where the part of the thread this client holds begins, while there is a page before it.
|
|
@@ -3,6 +3,7 @@ import { FileIcon, Icon, Menu, MiddleTruncate, ScrollArea } from '@adecore/ui';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { SquareSlash, Zap } from 'lucide-react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { MarkGlyph } from '../../../agents/AgentIcon.js';
|
|
6
7
|
import { CliMark } from '../../../agents/AgentModelLabel.js';
|
|
7
8
|
import { useChatHost } from '../../../host/host.js';
|
|
8
9
|
import { ModelMarks } from '../ModelMarks.js';
|
|
@@ -168,21 +169,30 @@ function SkillMenu(t0) {
|
|
|
168
169
|
t3 = menus.skillMatches.map((skill, index) => /*#__PURE__*/_jsxs(MenuOption, {
|
|
169
170
|
menus: menus,
|
|
170
171
|
index: index,
|
|
171
|
-
className: "items-
|
|
172
|
+
className: "items-center",
|
|
172
173
|
onPick: () => menus.chooseSkill(skill.name),
|
|
173
|
-
children: [/*#__PURE__*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
className: "truncate font-mono text-text",
|
|
174
|
+
children: [skill.host === null ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
175
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
176
|
+
icon: Zap,
|
|
177
|
+
size: 12,
|
|
178
|
+
className: "shrink-0 text-skill"
|
|
179
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
180
|
+
className: "shrink-0 font-mono text-text",
|
|
181
181
|
children: ["$", skill.name]
|
|
182
|
-
}), skill.description !== "" && /*#__PURE__*/_jsx("span", {
|
|
183
|
-
className: "line-clamp-1 text-text-faint",
|
|
184
|
-
children: skill.description
|
|
185
182
|
})]
|
|
183
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
184
|
+
children: [/*#__PURE__*/_jsx(MarkGlyph, {
|
|
185
|
+
mark: skill.host.icon,
|
|
186
|
+
size: 12,
|
|
187
|
+
decorative: true,
|
|
188
|
+
className: "shrink-0 text-skill"
|
|
189
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
190
|
+
className: "shrink-0 text-text",
|
|
191
|
+
children: skill.host.title
|
|
192
|
+
})]
|
|
193
|
+
}), skill.description !== "" && /*#__PURE__*/_jsx("span", {
|
|
194
|
+
className: "min-w-0 truncate text-text-faint",
|
|
195
|
+
children: skill.description
|
|
186
196
|
})]
|
|
187
197
|
}, skill.name));
|
|
188
198
|
$[2] = menus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
2
|
import { type ComponentType } from 'react';
|
|
3
|
-
import type { ReferenceIconProps } from '../../../host/host.js';
|
|
3
|
+
import type { HostSkill, ReferenceIconProps } from '../../../host/host.js';
|
|
4
4
|
import type { ReferableKind, ReferenceStep } from '../../../host/references.js';
|
|
5
5
|
import { type ReferenceToken } from '../../mentions.js';
|
|
6
6
|
import type { NamedChipLookup } from '../named-chip-look.js';
|
|
@@ -13,6 +13,7 @@ interface ChipChoices {
|
|
|
13
13
|
}>;
|
|
14
14
|
referenceIcon?: ComponentType<ReferenceIconProps> | null;
|
|
15
15
|
named?: NamedChipLookup | null;
|
|
16
|
+
hostSkills?: readonly HostSkill[];
|
|
16
17
|
}
|
|
17
18
|
export declare function chipDecorations(value: ChipChoices): Extension;
|
|
18
19
|
export {};
|
|
@@ -3,6 +3,7 @@ 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 { MarkGlyph } from '../../../agents/AgentIcon.js';
|
|
6
7
|
import { CliMark } from '../../../agents/AgentModelLabel.js';
|
|
7
8
|
import { chipRanges, withNamedChips } from '../../mentions.js';
|
|
8
9
|
import { CHIP_IN_EDITOR, MENTION_TONE, REFERENCE_TONE, SKILL_TONE, TOKEN_ICON_IN_EDITOR } from '../chips.js';
|
|
@@ -108,15 +109,48 @@ class NamedChipWidget extends WidgetType {
|
|
|
108
109
|
queueMicrotask(() => root?.unmount());
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
/* A skill of the host's own in place of its `$name`: the host's mark and the title. One atom, like a named chip. */
|
|
113
|
+
class HostSkillWidget extends WidgetType {
|
|
114
|
+
skill;
|
|
115
|
+
constructor(skill) {
|
|
116
|
+
super();
|
|
117
|
+
this.skill = skill;
|
|
118
|
+
}
|
|
119
|
+
eq(other) {
|
|
120
|
+
return other.skill.name === this.skill.name && other.skill.title === this.skill.title && other.skill.icon.path === this.skill.icon.path;
|
|
121
|
+
}
|
|
122
|
+
toDOM() {
|
|
123
|
+
const chip = document.createElement('span');
|
|
124
|
+
const mark = document.createElement('span');
|
|
125
|
+
const root = createRoot(mark);
|
|
126
|
+
chip.className = `${SKILL_TONE} ${CHIP_IN_EDITOR}`;
|
|
127
|
+
mark.className = TOKEN_ICON_IN_EDITOR;
|
|
128
|
+
root.render(createElement(MarkGlyph, {
|
|
129
|
+
mark: this.skill.icon,
|
|
130
|
+
size: 12,
|
|
131
|
+
decorative: true
|
|
132
|
+
}));
|
|
133
|
+
roots.set(chip, root);
|
|
134
|
+
chip.append(mark, this.skill.title);
|
|
135
|
+
return chip;
|
|
136
|
+
}
|
|
137
|
+
destroy(dom) {
|
|
138
|
+
const root = roots.get(dom);
|
|
139
|
+
roots.delete(dom);
|
|
140
|
+
queueMicrotask(() => root?.unmount());
|
|
141
|
+
}
|
|
142
|
+
}
|
|
111
143
|
function chipMarks(state) {
|
|
112
144
|
const {
|
|
113
145
|
mentions,
|
|
114
146
|
skills,
|
|
115
147
|
references = [],
|
|
116
148
|
referenceIcon = null,
|
|
117
|
-
named = null
|
|
149
|
+
named = null,
|
|
150
|
+
hostSkills = []
|
|
118
151
|
} = state.facet(choices);
|
|
119
152
|
const tokens = new Map(references.map(token => [token.id, token]));
|
|
153
|
+
const hosted = new Map(hostSkills.map(skill => [skill.name, skill]));
|
|
120
154
|
const marks = [];
|
|
121
155
|
const atoms = [];
|
|
122
156
|
const text = state.doc.toString();
|
|
@@ -138,6 +172,15 @@ function chipMarks(state) {
|
|
|
138
172
|
atoms.push(atom);
|
|
139
173
|
continue;
|
|
140
174
|
}
|
|
175
|
+
const hostSkill = range.kind === 'skill' ? hosted.get(range.value) : undefined;
|
|
176
|
+
if (hostSkill !== undefined) {
|
|
177
|
+
const atom = Decoration.replace({
|
|
178
|
+
widget: new HostSkillWidget(hostSkill)
|
|
179
|
+
}).range(range.from, range.to);
|
|
180
|
+
marks.push(atom);
|
|
181
|
+
atoms.push(atom);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
141
184
|
if (range.kind !== 'reference') {
|
|
142
185
|
marks.push((range.kind === 'skill' ? skillMark : mentionMark).range(range.from, range.to));
|
|
143
186
|
continue;
|
|
@@ -4,6 +4,7 @@ import type { ComposerSend } from '../../composer-send.js';
|
|
|
4
4
|
import type { ChatSendKey } from '../../send-key.js';
|
|
5
5
|
import type { ComposerMenus } from './use-composer-menus.js';
|
|
6
6
|
import type { PromptHistory } from './use-prompt-history.js';
|
|
7
|
+
import type { PromptSuggestion } from './use-prompt-suggestion.js';
|
|
7
8
|
interface KeyHandlerInput {
|
|
8
9
|
chatId: string;
|
|
9
10
|
host: Pick<ChatHost, 'isApplePlatform' | 'isAppShortcut' | 'openNewChat'>;
|
|
@@ -12,6 +13,7 @@ interface KeyHandlerInput {
|
|
|
12
13
|
menus: ComposerMenus;
|
|
13
14
|
history: PromptHistory;
|
|
14
15
|
noteKey(e: KeyboardEvent): void;
|
|
16
|
+
suggestion: PromptSuggestion | null;
|
|
15
17
|
toggleStash(): void;
|
|
16
18
|
submit(how: ComposerSend): void;
|
|
17
19
|
}
|
|
@@ -149,12 +149,18 @@ export function composerKeyHandler(input) {
|
|
|
149
149
|
chatId,
|
|
150
150
|
host,
|
|
151
151
|
text,
|
|
152
|
-
history
|
|
152
|
+
history,
|
|
153
|
+
suggestion
|
|
153
154
|
} = input;
|
|
154
155
|
return (e, view) => {
|
|
155
156
|
input.noteKey(e);
|
|
156
|
-
// Escape leaves the node, unless it first has a
|
|
157
|
+
// Escape leaves the node, unless it first has a predicted prompt to wave off or a recalled one to put back.
|
|
157
158
|
if (e.key === 'Escape' && !e.isComposing) {
|
|
159
|
+
if (suggestion !== null) {
|
|
160
|
+
suggestion.dismiss();
|
|
161
|
+
e.stopPropagation();
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
158
164
|
if (!history.leave()) {
|
|
159
165
|
return false;
|
|
160
166
|
}
|
|
@@ -184,6 +190,10 @@ export function composerKeyHandler(input) {
|
|
|
184
190
|
if (e.key === 'Tab' && !e.altKey && !e.metaKey && !e.ctrlKey && indentInFence(e, view)) {
|
|
185
191
|
return true;
|
|
186
192
|
}
|
|
193
|
+
if (e.key === 'Tab' && !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey && suggestion !== null) {
|
|
194
|
+
suggestion.accept();
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
187
197
|
if (e.key === 'Enter') {
|
|
188
198
|
return enter(e, view, input);
|
|
189
199
|
}
|
|
@@ -13,6 +13,7 @@ interface PlaceholderInput extends HintConditions {
|
|
|
13
13
|
chatId: string;
|
|
14
14
|
disabled: boolean;
|
|
15
15
|
readOnly: boolean;
|
|
16
|
+
suggestion: string | null;
|
|
16
17
|
}
|
|
17
|
-
export declare function useHintedPlaceholder({ chatId, disabled, readOnly, mentionable, referable, hasSkills }: PlaceholderInput): string | HTMLElement;
|
|
18
|
+
export declare function useHintedPlaceholder({ chatId, disabled, readOnly, suggestion, mentionable, referable, hasSkills }: PlaceholderInput): string | HTMLElement;
|
|
18
19
|
export {};
|
|
@@ -41,13 +41,17 @@ function hintedPlaceholder(lead, joiner, hints) {
|
|
|
41
41
|
root.append(lead, extra);
|
|
42
42
|
return root;
|
|
43
43
|
}
|
|
44
|
-
/*
|
|
44
|
+
/*
|
|
45
|
+
* What the empty box says: why nothing can be written, the next prompt the CLI predicted and the key that fills it in,
|
|
46
|
+
* or the host's words and the keys that open a picker.
|
|
47
|
+
*/
|
|
45
48
|
export function useHintedPlaceholder(t0) {
|
|
46
|
-
const $ = _c(
|
|
49
|
+
const $ = _c(13);
|
|
47
50
|
const {
|
|
48
51
|
chatId,
|
|
49
52
|
disabled,
|
|
50
53
|
readOnly,
|
|
54
|
+
suggestion,
|
|
51
55
|
mentionable,
|
|
52
56
|
referable,
|
|
53
57
|
hasSkills
|
|
@@ -83,21 +87,38 @@ export function useHintedPlaceholder(t0) {
|
|
|
83
87
|
t1 = t2;
|
|
84
88
|
break bb0;
|
|
85
89
|
}
|
|
90
|
+
if (suggestion !== null) {
|
|
91
|
+
let predicted;
|
|
92
|
+
if ($[4] !== suggestion || $[5] !== t) {
|
|
93
|
+
predicted = hintedPlaceholder(suggestion, "", [{
|
|
94
|
+
key: "Tab",
|
|
95
|
+
label: t("composer.placeholder.suggestion")
|
|
96
|
+
}]);
|
|
97
|
+
predicted.classList.add("composer-suggestion");
|
|
98
|
+
$[4] = suggestion;
|
|
99
|
+
$[5] = t;
|
|
100
|
+
$[6] = predicted;
|
|
101
|
+
} else {
|
|
102
|
+
predicted = $[6];
|
|
103
|
+
}
|
|
104
|
+
t1 = predicted;
|
|
105
|
+
break bb0;
|
|
106
|
+
}
|
|
86
107
|
let t2;
|
|
87
|
-
if ($[
|
|
108
|
+
if ($[7] !== hasSkills || $[8] !== lead || $[9] !== mentionable || $[10] !== referable || $[11] !== t) {
|
|
88
109
|
t2 = hintedPlaceholder(lead ?? t("composer.placeholder.lead"), t("composer.placeholder.joiner"), placeholderHints(t, {
|
|
89
110
|
mentionable,
|
|
90
111
|
referable,
|
|
91
112
|
hasSkills
|
|
92
113
|
}));
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
114
|
+
$[7] = hasSkills;
|
|
115
|
+
$[8] = lead;
|
|
116
|
+
$[9] = mentionable;
|
|
117
|
+
$[10] = referable;
|
|
118
|
+
$[11] = t;
|
|
119
|
+
$[12] = t2;
|
|
99
120
|
} else {
|
|
100
|
-
t2 = $[
|
|
121
|
+
t2 = $[12];
|
|
101
122
|
}
|
|
102
123
|
t1 = t2;
|
|
103
124
|
}
|
|
@@ -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 { useHostAccountRule, useHostReferables } from '../../../host/host-hooks.js';
|
|
4
|
+
import { useHostAccountRule, useHostReferables, useHostSkills } from '../../../host/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
|
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(34);
|
|
12
12
|
const {
|
|
13
13
|
chatId,
|
|
14
14
|
info,
|
|
@@ -23,6 +23,7 @@ export function useComposerMenus(t0) {
|
|
|
23
23
|
const scope = useChatScope();
|
|
24
24
|
const referables = useHostReferables(scope.id, chatId);
|
|
25
25
|
const accountRule = useHostAccountRule(scope.id, chatId);
|
|
26
|
+
const hostSkills = useHostSkills(scope.id, chatId);
|
|
26
27
|
let t1;
|
|
27
28
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
29
|
t1 = [];
|
|
@@ -32,10 +33,11 @@ export function useComposerMenus(t0) {
|
|
|
32
33
|
}
|
|
33
34
|
const [skills, setSkills] = useState(t1);
|
|
34
35
|
let t2;
|
|
35
|
-
if ($[1] !== chatId || $[2] !== scope.chats) {
|
|
36
|
+
if ($[1] !== chatId || $[2] !== info.cwd || $[3] !== info.provider || $[4] !== info.running || $[5] !== info.skills || $[6] !== scope.chats) {
|
|
36
37
|
t2 = () => {
|
|
37
38
|
let stale = false;
|
|
38
|
-
|
|
39
|
+
const alike = info.running ? undefined : JSON.stringify([info.provider, info.cwd, info.skills ?? null]);
|
|
40
|
+
scope.chats.listSkills(chatId, alike).then(found => {
|
|
39
41
|
if (!stale) {
|
|
40
42
|
setSkills(found);
|
|
41
43
|
}
|
|
@@ -45,53 +47,60 @@ export function useComposerMenus(t0) {
|
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
49
|
$[1] = chatId;
|
|
48
|
-
$[2] =
|
|
49
|
-
$[3] =
|
|
50
|
+
$[2] = info.cwd;
|
|
51
|
+
$[3] = info.provider;
|
|
52
|
+
$[4] = info.running;
|
|
53
|
+
$[5] = info.skills;
|
|
54
|
+
$[6] = scope.chats;
|
|
55
|
+
$[7] = t2;
|
|
50
56
|
} else {
|
|
51
|
-
t2 = $[
|
|
57
|
+
t2 = $[7];
|
|
52
58
|
}
|
|
53
59
|
let t3;
|
|
54
|
-
if ($[
|
|
55
|
-
t3 = [scope, chatId, info.skills, info.running];
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
60
|
+
if ($[8] !== chatId || $[9] !== info.cwd || $[10] !== info.provider || $[11] !== info.running || $[12] !== info.skills || $[13] !== scope) {
|
|
61
|
+
t3 = [scope, chatId, info.provider, info.cwd, info.skills, info.running];
|
|
62
|
+
$[8] = chatId;
|
|
63
|
+
$[9] = info.cwd;
|
|
64
|
+
$[10] = info.provider;
|
|
65
|
+
$[11] = info.running;
|
|
66
|
+
$[12] = info.skills;
|
|
67
|
+
$[13] = scope;
|
|
68
|
+
$[14] = t3;
|
|
61
69
|
} else {
|
|
62
|
-
t3 = $[
|
|
70
|
+
t3 = $[14];
|
|
63
71
|
}
|
|
64
72
|
useEffect(t2, t3);
|
|
65
73
|
const t4 = capabilities?.mentions === false ? null : info.cwd;
|
|
66
74
|
const t5 = info.slashCommands;
|
|
67
75
|
const t6 = capabilities?.goals !== undefined;
|
|
68
76
|
let t7;
|
|
69
|
-
if ($[
|
|
77
|
+
if ($[15] !== t) {
|
|
70
78
|
t7 = t("composer.inputLabel");
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
79
|
+
$[15] = t;
|
|
80
|
+
$[16] = t7;
|
|
73
81
|
} else {
|
|
74
|
-
t7 = $[
|
|
82
|
+
t7 = $[16];
|
|
75
83
|
}
|
|
76
84
|
let t8;
|
|
77
|
-
if ($[
|
|
85
|
+
if ($[17] !== info.account || $[18] !== info.provider) {
|
|
78
86
|
t8 = {
|
|
79
87
|
provider: info.provider,
|
|
80
88
|
account: info.account
|
|
81
89
|
};
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
90
|
+
$[17] = info.account;
|
|
91
|
+
$[18] = info.provider;
|
|
92
|
+
$[19] = t8;
|
|
85
93
|
} else {
|
|
86
|
-
t8 = $[
|
|
94
|
+
t8 = $[19];
|
|
87
95
|
}
|
|
88
96
|
let t9;
|
|
89
|
-
if ($[
|
|
97
|
+
if ($[20] !== accountRule || $[21] !== chatId || $[22] !== draft || $[23] !== hostSkills || $[24] !== info.slashCommands || $[25] !== inputRef || $[26] !== providerName || $[27] !== referables || $[28] !== skills || $[29] !== t4 || $[30] !== t6 || $[31] !== t7 || $[32] !== t8) {
|
|
90
98
|
t9 = {
|
|
91
99
|
draft,
|
|
92
100
|
inputRef,
|
|
93
101
|
cwd: t4,
|
|
94
102
|
skills,
|
|
103
|
+
hostSkills,
|
|
95
104
|
slashCommands: t5,
|
|
96
105
|
localCommands: LOCAL_COMMANDS,
|
|
97
106
|
goals: t6,
|
|
@@ -102,21 +111,22 @@ export function useComposerMenus(t0) {
|
|
|
102
111
|
accountRule,
|
|
103
112
|
home: t8
|
|
104
113
|
};
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
114
|
+
$[20] = accountRule;
|
|
115
|
+
$[21] = chatId;
|
|
116
|
+
$[22] = draft;
|
|
117
|
+
$[23] = hostSkills;
|
|
118
|
+
$[24] = info.slashCommands;
|
|
119
|
+
$[25] = inputRef;
|
|
120
|
+
$[26] = providerName;
|
|
121
|
+
$[27] = referables;
|
|
122
|
+
$[28] = skills;
|
|
123
|
+
$[29] = t4;
|
|
124
|
+
$[30] = t6;
|
|
125
|
+
$[31] = t7;
|
|
126
|
+
$[32] = t8;
|
|
127
|
+
$[33] = t9;
|
|
118
128
|
} else {
|
|
119
|
-
t9 = $[
|
|
129
|
+
t9 = $[33];
|
|
120
130
|
}
|
|
121
131
|
return usePromptMenus(t9);
|
|
122
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 '../../../host/host.js';
|
|
4
|
+
import { type AccountRule, type HostSkill } from '../../../host/host.js';
|
|
5
5
|
import { type Referable, type Referables } from '../../../host/references.js';
|
|
6
6
|
import type { ChatDraft } from '../../drafts.js';
|
|
7
7
|
import { type MentionQuery, type NamedPick, type TextRange } from '../../mentions.js';
|
|
@@ -20,11 +20,17 @@ export interface ComposerCommand {
|
|
|
20
20
|
expand?(args: string): Promise<string>;
|
|
21
21
|
skill: boolean;
|
|
22
22
|
}
|
|
23
|
+
export interface SkillMatch {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
host: HostSkill | null;
|
|
27
|
+
}
|
|
23
28
|
interface PromptMenusInput<D extends PromptDraft> {
|
|
24
29
|
draft: PromptDraftBox<D>;
|
|
25
30
|
inputRef: RefObject<ComposerInputHandle | null>;
|
|
26
31
|
cwd: string | null;
|
|
27
32
|
skills: readonly ChatSkill[];
|
|
33
|
+
hostSkills?: readonly HostSkill[];
|
|
28
34
|
slashCommands: readonly string[];
|
|
29
35
|
localCommands?: readonly string[];
|
|
30
36
|
goals: boolean;
|
|
@@ -35,7 +41,7 @@ interface PromptMenusInput<D extends PromptDraft> {
|
|
|
35
41
|
accountRule?: AccountRule | null;
|
|
36
42
|
home?: NamedChipHome | null;
|
|
37
43
|
}
|
|
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>): {
|
|
44
|
+
export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft, setDraft, setText }, inputRef, cwd, skills, hostSkills, slashCommands, localCommands, goals, providerName, referables, ownId, label, accountRule, home }: PromptMenusInput<D>): {
|
|
39
45
|
listId: string;
|
|
40
46
|
activeIndex: number;
|
|
41
47
|
inputAria: Record<string, string>;
|
|
@@ -43,14 +49,11 @@ export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft,
|
|
|
43
49
|
hasSkills: boolean;
|
|
44
50
|
offersViews: boolean;
|
|
45
51
|
skillNames: string[];
|
|
52
|
+
hostSkills: readonly HostSkill[];
|
|
46
53
|
commandQuery: string | null;
|
|
47
54
|
commands: ComposerCommand[];
|
|
48
55
|
commandMenuOpen: boolean;
|
|
49
|
-
skillMatches:
|
|
50
|
-
name: string;
|
|
51
|
-
description: string;
|
|
52
|
-
source: "plugin" | "project" | "user";
|
|
53
|
-
}[];
|
|
56
|
+
skillMatches: SkillMatch[];
|
|
54
57
|
skillMenuOpen: boolean;
|
|
55
58
|
mention: MentionQuery | null;
|
|
56
59
|
mentionMenuOpen: boolean;
|