@adecore/agents-react 0.74.1 → 0.75.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/chat/mentions.d.ts +11 -2
- package/dist/chat/mentions.js +57 -18
- package/dist/chat/tag-suggestions.d.ts +3 -1
- package/dist/chat/tag-suggestions.js +54 -10
- package/dist/chat/ui/NamedChip.js +49 -44
- package/dist/chat/ui/ReferenceChip.d.ts +2 -1
- package/dist/chat/ui/ReferenceChip.js +64 -48
- package/dist/chat/ui/chip-clipboard.js +17 -6
- package/dist/chat/ui/composer/ComposerMenu.js +28 -24
- package/dist/chat/ui/composer/chips.js +19 -8
- package/dist/chat/ui/composer/use-prompt-menus.js +138 -137
- package/dist/chat/ui/named-chip-look.d.ts +2 -1
- package/dist/chat/ui/named-chip-look.js +18 -8
- package/dist/chat/ui/rehype-chips.js +6 -3
- package/package.json +9 -9
- package/src/chat/mentions.ts +69 -18
- package/src/chat/tag-suggestions.ts +73 -11
- package/src/chat/ui/NamedChip.tsx +10 -10
- package/src/chat/ui/ReferenceChip.tsx +4 -1
- package/src/chat/ui/chip-clipboard.ts +9 -5
- package/src/chat/ui/composer/ComposerMenu.tsx +6 -3
- package/src/chat/ui/composer/chips.ts +18 -7
- package/src/chat/ui/composer/use-prompt-menus.ts +2 -2
- package/src/chat/ui/named-chip-look.ts +19 -8
- package/src/chat/ui/rehype-chips.ts +7 -3
package/dist/chat/mentions.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type ChipSegment = {
|
|
|
39
39
|
kind: 'model';
|
|
40
40
|
cli: string;
|
|
41
41
|
id: string;
|
|
42
|
+
account?: string;
|
|
42
43
|
} | {
|
|
43
44
|
kind: 'account';
|
|
44
45
|
cli: string;
|
|
@@ -74,6 +75,7 @@ export interface NamedPick {
|
|
|
74
75
|
kind: NamedChipKind;
|
|
75
76
|
cli: string;
|
|
76
77
|
id: string;
|
|
78
|
+
account?: string;
|
|
77
79
|
}
|
|
78
80
|
type MentionPick = {
|
|
79
81
|
kind: 'file';
|
|
@@ -93,8 +95,15 @@ interface ChipRange extends TextRange {
|
|
|
93
95
|
kind: 'mention' | 'skill' | 'reference' | NamedChipKind;
|
|
94
96
|
value: string;
|
|
95
97
|
}
|
|
96
|
-
export declare function
|
|
97
|
-
export
|
|
98
|
+
export declare function namedChipValue(cli: string, id: string, account?: string): string;
|
|
99
|
+
export interface NamedChipParts {
|
|
100
|
+
cli: string;
|
|
101
|
+
id: string;
|
|
102
|
+
account: string | undefined;
|
|
103
|
+
}
|
|
104
|
+
export declare function namedChipParts(value: string): NamedChipParts | null;
|
|
105
|
+
export declare function namedChipToken(kind: NamedChipKind, cli: string, id: string, account?: string): string;
|
|
106
|
+
export declare function namedChipPrefix(kind: NamedChipKind, cli: string, account?: string): string;
|
|
98
107
|
export declare function namedChipRanges(text: string, excluded?: readonly TextRange[]): ChipRange[];
|
|
99
108
|
export declare function withNamedChips(text: string, picked: readonly ChipRange[], excluded?: readonly TextRange[]): ChipRange[];
|
|
100
109
|
export declare function chipRanges(text: string, mentions: string[], skills?: string[], excluded?: readonly TextRange[], references?: readonly ReferenceToken[]): ChipRange[];
|
package/dist/chat/mentions.js
CHANGED
|
@@ -239,8 +239,11 @@ export function chipText(segment) {
|
|
|
239
239
|
if (segment.kind === 'reference') {
|
|
240
240
|
return `#${segment.name}`;
|
|
241
241
|
}
|
|
242
|
-
if (segment.kind === 'model'
|
|
243
|
-
return namedChipToken(segment.
|
|
242
|
+
if (segment.kind === 'model') {
|
|
243
|
+
return namedChipToken('model', segment.cli, segment.id, segment.account);
|
|
244
|
+
}
|
|
245
|
+
if (segment.kind === 'account') {
|
|
246
|
+
return namedChipToken('account', segment.cli, segment.id);
|
|
244
247
|
}
|
|
245
248
|
return segment.text;
|
|
246
249
|
}
|
|
@@ -255,15 +258,36 @@ export function pastedMentions(text) {
|
|
|
255
258
|
}
|
|
256
259
|
return [...new Set(tokens.map(token => token.slice(1)))];
|
|
257
260
|
}
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
/* The token without its `@<kind>:`: `<cli>/<id>`, or `<cli>:<account>/<id>` for a model on one account. */
|
|
262
|
+
export function namedChipValue(cli, id, account) {
|
|
263
|
+
return `${namedChipHead(cli, account)}/${id}`;
|
|
264
|
+
}
|
|
265
|
+
/* What a `namedChipValue` holds, or null for one without a CLI. */
|
|
266
|
+
export function namedChipParts(value) {
|
|
267
|
+
const slash = value.indexOf('/');
|
|
268
|
+
if (slash < 1) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
const head = value.slice(0, slash);
|
|
272
|
+
const colon = head.indexOf(':');
|
|
273
|
+
return {
|
|
274
|
+
cli: colon < 0 ? head : head.slice(0, colon),
|
|
275
|
+
id: value.slice(slash + 1),
|
|
276
|
+
account: colon < 0 ? undefined : head.slice(colon + 1)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function namedChipHead(cli, account) {
|
|
280
|
+
return account === undefined ? cli : `${cli}:${account}`;
|
|
260
281
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return `@${kind}:${cli}/`;
|
|
282
|
+
export function namedChipToken(kind, cli, id, account) {
|
|
283
|
+
return `@${kind}:${namedChipValue(cli, id, account)}`;
|
|
264
284
|
}
|
|
265
|
-
|
|
266
|
-
|
|
285
|
+
/* The part of a named chip its CLI's mark stands in for: `@model:claude/`, or `@model:claude:claude_work/`. */
|
|
286
|
+
export function namedChipPrefix(kind, cli, account) {
|
|
287
|
+
return `@${kind}:${namedChipHead(cli, account)}/`;
|
|
288
|
+
}
|
|
289
|
+
// The id runs to whitespace or a backtick; a slash belongs to it (`openrouter/anthropic/claude`). The account is spelled as `ProviderAccountIdSchema` spells it.
|
|
290
|
+
const NAMED_CHIP = /@(model|account):([a-z0-9][a-z0-9-]*)(?::([a-z][a-z0-9_-]{0,63}))?\/([^\s`]+)/g;
|
|
267
291
|
// Punctuation after the id ends the sentence, except a `]` that closes a `[` in the id (`claude-opus-5-5[1m]`).
|
|
268
292
|
function trimmedId(id) {
|
|
269
293
|
let end = id.length;
|
|
@@ -281,16 +305,22 @@ export function namedChipRanges(text, excluded = []) {
|
|
|
281
305
|
const ranges = [];
|
|
282
306
|
for (const found of text.matchAll(NAMED_CHIP)) {
|
|
283
307
|
const from = found.index;
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
308
|
+
const kind = found[1];
|
|
309
|
+
const account = found[3];
|
|
310
|
+
const id = trimmedId(found[4]);
|
|
311
|
+
const to = from + found[0].length - (found[4].length - id.length);
|
|
312
|
+
// An account runs on no other account.
|
|
313
|
+
if (id === '' || kind === 'account' && account !== undefined) {
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (from > 0 && !REFERENCE_OPENER.test(text[from - 1]) || excluded.some(range => from < range.to && to > range.from)) {
|
|
287
317
|
continue;
|
|
288
318
|
}
|
|
289
319
|
ranges.push({
|
|
290
320
|
from,
|
|
291
321
|
to,
|
|
292
|
-
kind
|
|
293
|
-
value:
|
|
322
|
+
kind,
|
|
323
|
+
value: namedChipValue(found[2], id, account)
|
|
294
324
|
});
|
|
295
325
|
}
|
|
296
326
|
return ranges;
|
|
@@ -373,11 +403,20 @@ function segmentOf(text, range) {
|
|
|
373
403
|
};
|
|
374
404
|
}
|
|
375
405
|
if (range.kind === 'model' || range.kind === 'account') {
|
|
376
|
-
const
|
|
377
|
-
|
|
406
|
+
const {
|
|
407
|
+
cli,
|
|
408
|
+
id,
|
|
409
|
+
account
|
|
410
|
+
} = namedChipParts(range.value);
|
|
411
|
+
return range.kind === 'model' && account !== undefined ? {
|
|
412
|
+
kind: 'model',
|
|
413
|
+
cli,
|
|
414
|
+
id,
|
|
415
|
+
account
|
|
416
|
+
} : {
|
|
378
417
|
kind: range.kind,
|
|
379
|
-
cli
|
|
380
|
-
id
|
|
418
|
+
cli,
|
|
419
|
+
id
|
|
381
420
|
};
|
|
382
421
|
}
|
|
383
422
|
return {
|
|
@@ -2,11 +2,13 @@ import { type AgentKind, type ModelInfo, type ProviderAccounts, type ProviderInf
|
|
|
2
2
|
import { type AccountEntry } from '../agents/accounts.js';
|
|
3
3
|
import type { AccountRule } from '../host/host.js';
|
|
4
4
|
import type { NamedPick } from './mentions.js';
|
|
5
|
+
import type { NamedChipHome } from './ui/named-chip-look.js';
|
|
5
6
|
export interface ModelSuggestion extends NamedPick {
|
|
6
7
|
kind: 'model';
|
|
7
8
|
cli: AgentKind;
|
|
8
9
|
provider: ProviderInfo;
|
|
9
10
|
model: ModelInfo;
|
|
11
|
+
accountName?: string;
|
|
10
12
|
}
|
|
11
13
|
export interface AccountSuggestion extends NamedPick {
|
|
12
14
|
kind: 'account';
|
|
@@ -17,5 +19,5 @@ export interface AccountSuggestion extends NamedPick {
|
|
|
17
19
|
}
|
|
18
20
|
export declare function startsAWord(text: string, query: string): boolean;
|
|
19
21
|
export declare function signedIn(accounts: ProviderAccounts | null, kind: AgentKind): boolean;
|
|
20
|
-
export declare function modelSuggestions(providers: readonly ProviderInfo[], accounts: ProviderAccounts | null, query: string, reportedOf: (kind: AgentKind) => ReadonlySet<string
|
|
22
|
+
export declare function modelSuggestions(providers: readonly ProviderInfo[], accounts: ProviderAccounts | null, query: string, reportedOf: (kind: AgentKind) => ReadonlySet<string>, rule?: AccountRule | null, home?: NamedChipHome | null): ModelSuggestion[];
|
|
21
23
|
export declare function accountSuggestions(providers: readonly ProviderInfo[], accounts: ProviderAccounts | null, rule: AccountRule | null, query: string): AccountSuggestion[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inPickerOrder } from '@adecore/agent-contracts';
|
|
2
2
|
import { accountName, accountsOfKind, hasAccountChoice, projectOffered } from '../agents/accounts.js';
|
|
3
3
|
import { modelRequirementOf } from '../agents/model-requirement.js';
|
|
4
|
-
const MODEL_SUGGESTIONS =
|
|
4
|
+
const MODEL_SUGGESTIONS = 8;
|
|
5
5
|
const ACCOUNT_SUGGESTIONS = 3;
|
|
6
6
|
// A CLI no model runs under while its accounts say this.
|
|
7
7
|
const UNUSABLE = new Set(['signed-out', 'not-found', 'folder-missing', 'failed']);
|
|
@@ -29,21 +29,65 @@ export function signedIn(accounts, kind) {
|
|
|
29
29
|
}
|
|
30
30
|
return entries.some(entry => entry.account.enabled !== false && (entry.status === null || !UNUSABLE.has(entry.status.state)));
|
|
31
31
|
}
|
|
32
|
+
/*
|
|
33
|
+
* The accounts a CLI's models are offered on, the chat's own first: the ready ones the project offers. None
|
|
34
|
+
* while fewer than two are, so a CLI without a choice keeps rows of the model alone.
|
|
35
|
+
*/
|
|
36
|
+
function modelAccounts(provider, accounts, rule, home) {
|
|
37
|
+
const entries = accountsOfKind(accounts, provider.kind);
|
|
38
|
+
if (!hasAccountChoice(entries)) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const ready = projectOffered(entries, rule, provider.kind, undefined).filter(entry => entry.account.enabled !== false && entry.status?.state === 'ready');
|
|
42
|
+
if (ready.length < 2) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const first = home?.provider === provider.kind ? home.account ?? provider.kind : undefined;
|
|
46
|
+
return [...ready.filter(entry => entry.id === first), ...ready.filter(entry => entry.id !== first)].map(entry => ({
|
|
47
|
+
id: entry.id,
|
|
48
|
+
name: accountName(entry, provider.name)
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
32
51
|
/*
|
|
33
52
|
* The models the `@` list offers for a query: of a CLI that is installed, chats and is signed in, and
|
|
34
|
-
* that the CLI is new enough for.
|
|
53
|
+
* that the CLI is new enough for. A CLI with a choice of accounts offers a row per account, found by the
|
|
54
|
+
* account's name too, and `<account>/<model>` narrows to both. Legacy models last, at most
|
|
55
|
+
* `MODEL_SUGGESTIONS`. A bare `@` offers none.
|
|
35
56
|
*/
|
|
36
|
-
export function modelSuggestions(providers, accounts, query, reportedOf) {
|
|
57
|
+
export function modelSuggestions(providers, accounts, query, reportedOf, rule = null, home = null) {
|
|
37
58
|
if (query === '') {
|
|
38
59
|
return [];
|
|
39
60
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
const slash = query.indexOf('/');
|
|
62
|
+
const modelMatches = (model, words) => startsAWord(model.name, words) || startsAWord(model.slug, words);
|
|
63
|
+
// A slash may belong to a model's id (`openrouter/anthropic/claude`), so the whole query still finds a model.
|
|
64
|
+
const accountMatches = (model, account) => {
|
|
65
|
+
if (slash < 0) {
|
|
66
|
+
return startsAWord(account.name, query);
|
|
67
|
+
}
|
|
68
|
+
const rest = query.slice(slash + 1);
|
|
69
|
+
return startsAWord(account.name, query.slice(0, slash)) && (rest === '' || modelMatches(model, rest));
|
|
70
|
+
};
|
|
71
|
+
const found = inPickerOrder(providers.filter(entry => entry.installed && entry.capabilities.chat && signedIn(accounts, entry.kind))).flatMap(provider => {
|
|
72
|
+
const offered = modelAccounts(provider, accounts, rule, home);
|
|
73
|
+
return provider.models.filter(model => modelRequirementOf(model, provider, reportedOf(provider.kind)) === null).flatMap(model => {
|
|
74
|
+
const row = {
|
|
75
|
+
kind: 'model',
|
|
76
|
+
cli: provider.kind,
|
|
77
|
+
id: model.slug,
|
|
78
|
+
provider,
|
|
79
|
+
model
|
|
80
|
+
};
|
|
81
|
+
if (offered.length === 0) {
|
|
82
|
+
return modelMatches(model, query) ? [row] : [];
|
|
83
|
+
}
|
|
84
|
+
return offered.filter(account => modelMatches(model, query) || accountMatches(model, account)).map(account => ({
|
|
85
|
+
...row,
|
|
86
|
+
account: account.id,
|
|
87
|
+
accountName: account.name
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
47
91
|
return [...found.filter(entry => !entry.model.legacy), ...found.filter(entry => entry.model.legacy)].slice(0, MODEL_SUGGESTIONS);
|
|
48
92
|
}
|
|
49
93
|
/*
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { CliMark } from '../../agents/AgentModelLabel.js';
|
|
3
|
-
import { namedChipPrefix } from '../mentions.js';
|
|
3
|
+
import { namedChipParts, namedChipPrefix } from '../mentions.js';
|
|
4
4
|
import { REFERENCE_TONE, TOKEN_ICON_BOX } from './chips.js';
|
|
5
5
|
import { useNamedChipLookup } from './named-chip-look.js';
|
|
6
6
|
import { TokenChip } from './ReferenceChip.js';
|
|
7
7
|
/*
|
|
8
8
|
* A model or an account a message names, under its CLI's mark in the color of the account it runs on, and
|
|
9
|
-
* the name the machine knows it by. An id the machine does not know
|
|
9
|
+
* the name the machine knows it by, after its account's when it names one. An id the machine does not know
|
|
10
|
+
* keeps the id. A copy reads the token.
|
|
10
11
|
*/
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
export function NamedChip(t0) {
|
|
@@ -18,93 +19,97 @@ export function NamedChip(t0) {
|
|
|
18
19
|
const lookup = useNamedChipLookup();
|
|
19
20
|
let T0;
|
|
20
21
|
let cli;
|
|
21
|
-
let color;
|
|
22
22
|
let id;
|
|
23
|
-
let
|
|
23
|
+
let look;
|
|
24
24
|
let t1;
|
|
25
25
|
let t2;
|
|
26
26
|
let t3;
|
|
27
27
|
if ($[0] !== kind || $[1] !== lookup || $[2] !== value) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const {
|
|
29
|
+
cli: t4,
|
|
30
|
+
id: t5,
|
|
31
|
+
account
|
|
32
|
+
} = namedChipParts(value) ?? {
|
|
33
|
+
cli: "",
|
|
34
|
+
id: value,
|
|
35
|
+
account: undefined
|
|
36
|
+
};
|
|
37
|
+
cli = t4;
|
|
38
|
+
id = t5;
|
|
39
|
+
look = lookup(kind, cli, id, account);
|
|
35
40
|
T0 = TokenChip;
|
|
36
41
|
t1 = kind;
|
|
37
42
|
t2 = value;
|
|
38
|
-
t3 = namedChipPrefix(kind, cli);
|
|
43
|
+
t3 = namedChipPrefix(kind, cli, account);
|
|
39
44
|
$[0] = kind;
|
|
40
45
|
$[1] = lookup;
|
|
41
46
|
$[2] = value;
|
|
42
47
|
$[3] = T0;
|
|
43
48
|
$[4] = cli;
|
|
44
|
-
$[5] =
|
|
45
|
-
$[6] =
|
|
46
|
-
$[7] =
|
|
47
|
-
$[8] =
|
|
48
|
-
$[9] =
|
|
49
|
-
$[10] = t3;
|
|
49
|
+
$[5] = id;
|
|
50
|
+
$[6] = look;
|
|
51
|
+
$[7] = t1;
|
|
52
|
+
$[8] = t2;
|
|
53
|
+
$[9] = t3;
|
|
50
54
|
} else {
|
|
51
55
|
T0 = $[3];
|
|
52
56
|
cli = $[4];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
t3 = $[10];
|
|
57
|
+
id = $[5];
|
|
58
|
+
look = $[6];
|
|
59
|
+
t1 = $[7];
|
|
60
|
+
t2 = $[8];
|
|
61
|
+
t3 = $[9];
|
|
59
62
|
}
|
|
60
63
|
let t4;
|
|
61
|
-
if ($[
|
|
62
|
-
t4 = color === undefined ? undefined : {
|
|
63
|
-
color
|
|
64
|
+
if ($[10] !== look.color) {
|
|
65
|
+
t4 = look.color === undefined ? undefined : {
|
|
66
|
+
color: look.color
|
|
64
67
|
};
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
68
|
+
$[10] = look.color;
|
|
69
|
+
$[11] = t4;
|
|
67
70
|
} else {
|
|
68
|
-
t4 = $[
|
|
71
|
+
t4 = $[11];
|
|
69
72
|
}
|
|
70
73
|
let t5;
|
|
71
|
-
if ($[
|
|
74
|
+
if ($[12] !== cli) {
|
|
72
75
|
t5 = /*#__PURE__*/_jsx(CliMark, {
|
|
73
76
|
kind: cli,
|
|
74
77
|
size: 14
|
|
75
78
|
});
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
79
|
+
$[12] = cli;
|
|
80
|
+
$[13] = t5;
|
|
78
81
|
} else {
|
|
79
|
-
t5 = $[
|
|
82
|
+
t5 = $[13];
|
|
80
83
|
}
|
|
81
84
|
let t6;
|
|
82
|
-
if ($[
|
|
85
|
+
if ($[14] !== t4 || $[15] !== t5) {
|
|
83
86
|
t6 = /*#__PURE__*/_jsx("span", {
|
|
84
87
|
className: TOKEN_ICON_BOX,
|
|
85
88
|
style: t4,
|
|
86
89
|
children: t5
|
|
87
90
|
});
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
+
$[14] = t4;
|
|
92
|
+
$[15] = t5;
|
|
93
|
+
$[16] = t6;
|
|
91
94
|
} else {
|
|
92
|
-
t6 = $[
|
|
95
|
+
t6 = $[16];
|
|
93
96
|
}
|
|
94
|
-
const t7 = label === id ? undefined : id;
|
|
97
|
+
const t7 = look.label === id ? undefined : id;
|
|
95
98
|
let t8;
|
|
96
|
-
if ($[
|
|
99
|
+
if ($[17] !== T0 || $[18] !== look.account || $[19] !== look.label || $[20] !== t1 || $[21] !== t2 || $[22] !== t3 || $[23] !== t6 || $[24] !== t7) {
|
|
97
100
|
t8 = /*#__PURE__*/_jsx(T0, {
|
|
98
101
|
kind: t1,
|
|
99
102
|
value: t2,
|
|
100
103
|
sigil: t3,
|
|
101
104
|
icon: t6,
|
|
102
|
-
label: label,
|
|
105
|
+
label: look.label,
|
|
106
|
+
prefix: look.account,
|
|
103
107
|
spelled: t7,
|
|
104
108
|
tone: REFERENCE_TONE
|
|
105
109
|
});
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
110
|
+
$[17] = T0;
|
|
111
|
+
$[18] = look.account;
|
|
112
|
+
$[19] = look.label;
|
|
108
113
|
$[20] = t1;
|
|
109
114
|
$[21] = t2;
|
|
110
115
|
$[22] = t3;
|
|
@@ -5,11 +5,12 @@ interface TokenChipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children
|
|
|
5
5
|
sigil?: string;
|
|
6
6
|
icon: ReactNode;
|
|
7
7
|
label: string;
|
|
8
|
+
prefix?: string;
|
|
8
9
|
spelled?: string;
|
|
9
10
|
tone: string;
|
|
10
11
|
onOpen?: () => void;
|
|
11
12
|
}
|
|
12
|
-
export declare function TokenChip({ kind, value, sigil, icon, label, spelled, tone, onOpen, className, ...rest }: TokenChipProps): import("react").JSX.Element;
|
|
13
|
+
export declare function TokenChip({ kind, value, sigil, icon, label, prefix, spelled, tone, onOpen, className, ...rest }: TokenChipProps): import("react").JSX.Element;
|
|
13
14
|
export declare function ReferenceChip({ id, lastName, goneHint }: {
|
|
14
15
|
id: string;
|
|
15
16
|
lastName?: string;
|
|
@@ -16,12 +16,13 @@ import { ReferenceTrail } from './ReferenceTrail.js';
|
|
|
16
16
|
*/
|
|
17
17
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
18
|
export function TokenChip(t0) {
|
|
19
|
-
const $ = _c(
|
|
19
|
+
const $ = _c(38);
|
|
20
20
|
let className;
|
|
21
21
|
let icon;
|
|
22
22
|
let kind;
|
|
23
23
|
let label;
|
|
24
24
|
let onOpen;
|
|
25
|
+
let prefix;
|
|
25
26
|
let rest;
|
|
26
27
|
let sigil;
|
|
27
28
|
let spelled;
|
|
@@ -35,6 +36,7 @@ export function TokenChip(t0) {
|
|
|
35
36
|
sigil,
|
|
36
37
|
icon,
|
|
37
38
|
label,
|
|
39
|
+
prefix,
|
|
38
40
|
spelled,
|
|
39
41
|
tone,
|
|
40
42
|
onOpen,
|
|
@@ -53,55 +55,68 @@ export function TokenChip(t0) {
|
|
|
53
55
|
$[3] = kind;
|
|
54
56
|
$[4] = label;
|
|
55
57
|
$[5] = onOpen;
|
|
56
|
-
$[6] =
|
|
57
|
-
$[7] =
|
|
58
|
-
$[8] =
|
|
59
|
-
$[9] =
|
|
60
|
-
$[10] =
|
|
61
|
-
$[11] =
|
|
58
|
+
$[6] = prefix;
|
|
59
|
+
$[7] = rest;
|
|
60
|
+
$[8] = sigil;
|
|
61
|
+
$[9] = spelled;
|
|
62
|
+
$[10] = t1;
|
|
63
|
+
$[11] = tone;
|
|
64
|
+
$[12] = value;
|
|
62
65
|
} else {
|
|
63
66
|
className = $[1];
|
|
64
67
|
icon = $[2];
|
|
65
68
|
kind = $[3];
|
|
66
69
|
label = $[4];
|
|
67
70
|
onOpen = $[5];
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
prefix = $[6];
|
|
72
|
+
rest = $[7];
|
|
73
|
+
sigil = $[8];
|
|
74
|
+
spelled = $[9];
|
|
75
|
+
t1 = $[10];
|
|
76
|
+
tone = $[11];
|
|
77
|
+
value = $[12];
|
|
74
78
|
}
|
|
75
79
|
const onKeyDown = t1;
|
|
76
80
|
const t2 = onOpen !== undefined && "cursor-pointer focus-visible:outline-2 focus-visible:outline-accent-on-surface";
|
|
77
81
|
let t3;
|
|
78
|
-
if ($[
|
|
82
|
+
if ($[13] !== className || $[14] !== t2 || $[15] !== tone) {
|
|
79
83
|
t3 = clsx("not-prose", TOKEN_IN_MESSAGE, tone, t2, className);
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
+
$[13] = className;
|
|
85
|
+
$[14] = t2;
|
|
86
|
+
$[15] = tone;
|
|
87
|
+
$[16] = t3;
|
|
84
88
|
} else {
|
|
85
|
-
t3 = $[
|
|
89
|
+
t3 = $[16];
|
|
86
90
|
}
|
|
87
91
|
const t4 = kind === "reference" ? label : undefined;
|
|
88
92
|
const t5 = onOpen === undefined ? undefined : "button";
|
|
89
93
|
const t6 = onOpen === undefined ? undefined : 0;
|
|
90
94
|
const t7 = onOpen === undefined ? undefined : onKeyDown;
|
|
91
95
|
let t8;
|
|
92
|
-
if ($[
|
|
96
|
+
if ($[17] !== sigil) {
|
|
93
97
|
t8 = sigil !== undefined && /*#__PURE__*/_jsx("span", {
|
|
94
98
|
className: "sr-only",
|
|
95
99
|
children: sigil
|
|
96
100
|
});
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
101
|
+
$[17] = sigil;
|
|
102
|
+
$[18] = t8;
|
|
99
103
|
} else {
|
|
100
|
-
t8 = $[
|
|
104
|
+
t8 = $[18];
|
|
101
105
|
}
|
|
102
106
|
let t9;
|
|
103
|
-
if ($[
|
|
104
|
-
t9 =
|
|
107
|
+
if ($[19] !== prefix) {
|
|
108
|
+
t9 = prefix !== undefined && /*#__PURE__*/_jsx("span", {
|
|
109
|
+
className: "text-text-muted select-none",
|
|
110
|
+
children: `${prefix} / `
|
|
111
|
+
});
|
|
112
|
+
$[19] = prefix;
|
|
113
|
+
$[20] = t9;
|
|
114
|
+
} else {
|
|
115
|
+
t9 = $[20];
|
|
116
|
+
}
|
|
117
|
+
let t10;
|
|
118
|
+
if ($[21] !== label || $[22] !== spelled) {
|
|
119
|
+
t10 = spelled === undefined ? label : /*#__PURE__*/_jsxs(_Fragment, {
|
|
105
120
|
children: [/*#__PURE__*/_jsx("span", {
|
|
106
121
|
"aria-hidden": true,
|
|
107
122
|
className: "sr-only",
|
|
@@ -111,15 +126,15 @@ export function TokenChip(t0) {
|
|
|
111
126
|
children: label
|
|
112
127
|
})]
|
|
113
128
|
});
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
129
|
+
$[21] = label;
|
|
130
|
+
$[22] = spelled;
|
|
131
|
+
$[23] = t10;
|
|
117
132
|
} else {
|
|
118
|
-
|
|
133
|
+
t10 = $[23];
|
|
119
134
|
}
|
|
120
|
-
let
|
|
121
|
-
if ($[
|
|
122
|
-
|
|
135
|
+
let t11;
|
|
136
|
+
if ($[24] !== icon || $[25] !== kind || $[26] !== onOpen || $[27] !== rest || $[28] !== t10 || $[29] !== t3 || $[30] !== t4 || $[31] !== t5 || $[32] !== t6 || $[33] !== t7 || $[34] !== t8 || $[35] !== t9 || $[36] !== value) {
|
|
137
|
+
t11 = /*#__PURE__*/_jsxs("span", {
|
|
123
138
|
...rest,
|
|
124
139
|
className: t3,
|
|
125
140
|
"data-chip": kind,
|
|
@@ -129,25 +144,26 @@ export function TokenChip(t0) {
|
|
|
129
144
|
tabIndex: t6,
|
|
130
145
|
onClick: onOpen,
|
|
131
146
|
onKeyDown: t7,
|
|
132
|
-
children: [icon, t8, t9]
|
|
147
|
+
children: [icon, t8, t9, t10]
|
|
133
148
|
});
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
149
|
+
$[24] = icon;
|
|
150
|
+
$[25] = kind;
|
|
151
|
+
$[26] = onOpen;
|
|
152
|
+
$[27] = rest;
|
|
153
|
+
$[28] = t10;
|
|
154
|
+
$[29] = t3;
|
|
155
|
+
$[30] = t4;
|
|
156
|
+
$[31] = t5;
|
|
157
|
+
$[32] = t6;
|
|
158
|
+
$[33] = t7;
|
|
159
|
+
$[34] = t8;
|
|
160
|
+
$[35] = t9;
|
|
161
|
+
$[36] = value;
|
|
162
|
+
$[37] = t11;
|
|
147
163
|
} else {
|
|
148
|
-
|
|
164
|
+
t11 = $[37];
|
|
149
165
|
}
|
|
150
|
-
return
|
|
166
|
+
return t11;
|
|
151
167
|
}
|
|
152
168
|
/*
|
|
153
169
|
* A view, node or chat a message points at, under the name it has now. One that went says so, under
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { copyText } from '@adecore/ui';
|
|
2
2
|
import { referenceTokens } from '../chat-references.js';
|
|
3
|
-
import { clipboardChipsOf, hasClipboardChips, tokenizeChips, tokenizeNamedReferences, writeClipboardChips } from '../mentions.js';
|
|
3
|
+
import { clipboardChipsOf, hasClipboardChips, namedChipParts, tokenizeChips, tokenizeNamedReferences, writeClipboardChips } from '../mentions.js';
|
|
4
4
|
/* The chips a copy of a whole message carries: what the person picked, or what a reply names. */
|
|
5
5
|
export function messageClipboardChips(item, text, lookup) {
|
|
6
6
|
if (item.kind === 'assistant') {
|
|
@@ -43,13 +43,24 @@ function segmentOf(chip) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
case 'model':
|
|
46
|
+
{
|
|
47
|
+
const parts = namedChipParts(value);
|
|
48
|
+
return parts === null ? null : {
|
|
49
|
+
kind: 'model',
|
|
50
|
+
cli: parts.cli,
|
|
51
|
+
id: parts.id,
|
|
52
|
+
...(parts.account === undefined ? {} : {
|
|
53
|
+
account: parts.account
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
46
57
|
case 'account':
|
|
47
58
|
{
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
kind:
|
|
51
|
-
cli:
|
|
52
|
-
id:
|
|
59
|
+
const parts = namedChipParts(value);
|
|
60
|
+
return parts === null ? null : {
|
|
61
|
+
kind: 'account',
|
|
62
|
+
cli: parts.cli,
|
|
63
|
+
id: parts.id
|
|
53
64
|
};
|
|
54
65
|
}
|
|
55
66
|
default:
|