@adroit-app/chat-ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +151 -2
- package/dist/attach.d.ts +18 -0
- package/dist/attach.js +52 -0
- package/dist/chat.d.ts +330 -0
- package/dist/chat.js +2090 -0
- package/dist/composer.d.ts +27 -0
- package/dist/composer.js +46 -0
- package/dist/follow.d.ts +12 -0
- package/dist/follow.js +91 -0
- package/dist/form.d.ts +12 -0
- package/dist/form.js +15 -0
- package/dist/icons.d.ts +56 -0
- package/dist/icons.js +128 -0
- package/dist/image-actions.d.ts +33 -0
- package/dist/image-actions.js +10 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/keymap.d.ts +29 -0
- package/dist/keymap.js +69 -0
- package/dist/markdown/frontend.d.ts +6 -0
- package/dist/markdown/frontend.js +103 -0
- package/dist/markdown/picture.d.ts +22 -0
- package/dist/markdown/picture.js +57 -0
- package/dist/markdown/render.d.ts +71 -0
- package/dist/markdown/render.js +183 -0
- package/dist/markdown/view.d.ts +28 -0
- package/dist/markdown/view.js +39 -0
- package/dist/read.d.ts +32 -0
- package/dist/read.js +149 -0
- package/dist/scale.d.ts +7 -0
- package/dist/scale.js +9 -0
- package/dist/styles.d.ts +4 -0
- package/dist/styles.js +2166 -0
- package/dist/tools.d.ts +175 -0
- package/dist/tools.js +487 -0
- package/dist/view.d.ts +33 -0
- package/dist/view.js +37 -0
- package/dist/viewer.d.ts +78 -0
- package/dist/viewer.js +496 -0
- package/package.json +29 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alisue <lambdalisue@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,152 @@
|
|
|
1
|
-
#
|
|
1
|
+
# adroit-chat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://crates.io/crates/adroit-chat)
|
|
4
|
+
[](https://www.npmjs.com/package/@adroit-app/chat-core)
|
|
5
|
+
[](https://www.npmjs.com/package/@adroit-app/chat-ui)
|
|
6
|
+
[](https://www.npmjs.com/package/@adroit-app/chat-tauri)
|
|
7
|
+
[](https://www.npmjs.com/package/@adroit-app/session-start)
|
|
8
|
+
|
|
9
|
+
A chat window for any coding agent that speaks the
|
|
10
|
+
[Agent Client Protocol](https://agentclientprotocol.com).
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import "@adroit-app/chat-ui";
|
|
14
|
+
import { fromV1 } from "@adroit-app/chat-core";
|
|
15
|
+
|
|
16
|
+
const chat = document.createElement("adroit-chat");
|
|
17
|
+
chat.theme = "dark";
|
|
18
|
+
chat.cwd = "/path/to/project";
|
|
19
|
+
chat.connection = fromV1(session); // or an ACP v2 ChatConnection as it is
|
|
20
|
+
document.body.append(chat);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`<adroit-chat>` shows one ACP session: the transcript of what the agent said
|
|
24
|
+
and did, the asks it waits on, the plan, the prompts it holds, and a composer
|
|
25
|
+
to prompt it. Its only input is a connection to the session. What it takes
|
|
26
|
+
and promises is in [docs/spec/adroit-chat.md](docs/spec/adroit-chat.md).
|
|
27
|
+
|
|
28
|
+
The repository is <https://github.com/adroit-app/adroit-chat>.
|
|
29
|
+
|
|
30
|
+
## The window
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
adroit-chat claude [--model <model>] [--resume <session>]
|
|
34
|
+
adroit-chat codex [--model <model>] [--resume <thread>]
|
|
35
|
+
adroit-chat --acp -- <agent that speaks ACP>…
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Adroit Chat, started as `adroit-chat`, opens a window with the Chat on one agent's session, in the
|
|
39
|
+
current folder (or `--cwd <dir>`). `claude` runs your own Claude Code and
|
|
40
|
+
`codex` your own Codex, installed and signed in, through
|
|
41
|
+
[acp-adapter](https://github.com/adroit-app/acp-adapter) inside the program;
|
|
42
|
+
`--acp` runs any agent that speaks ACP. Started with no agent, as from Finder,
|
|
43
|
+
it opens a start form to choose the agent and the folder; File › New Window
|
|
44
|
+
opens another window, each with its own session. The composer's keys can be set in a
|
|
45
|
+
settings file; where it lives and what it holds is in
|
|
46
|
+
[docs/spec/app.md](docs/spec/app.md). Settings… opens a Preferences window over that
|
|
47
|
+
file.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
The window, on macOS (Apple silicon), with its `adroit-chat` command:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
brew install --cask adroit-app/tap/adroit-chat
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Each [release](https://github.com/adroit-app/adroit-chat/releases) carries
|
|
58
|
+
the window's bundles, with a `.sha256` for each: the disk image for macOS
|
|
59
|
+
(Apple silicon), the `.deb` and `.AppImage` for Linux (x86_64, aarch64), and
|
|
60
|
+
the installer for Windows (x86_64). The app is signed by a self-signed
|
|
61
|
+
certificate and not notarized; the cask lifts the quarantine Gatekeeper
|
|
62
|
+
would refuse it under. It can also be built from this repository (see
|
|
63
|
+
Development), with `just build` for the bundled app or
|
|
64
|
+
`just run -- claude` to run it from source.
|
|
65
|
+
|
|
66
|
+
What a host embeds the Chat with is published at each release:
|
|
67
|
+
|
|
68
|
+
| Package | What it is | Published to |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `@adroit-app/chat-core` | the view model of a session, its controller, and the ACP v1 adapter | [](https://www.npmjs.com/package/@adroit-app/chat-core) |
|
|
71
|
+
| `@adroit-app/chat-ui` | the `<adroit-chat>` element | [](https://www.npmjs.com/package/@adroit-app/chat-ui) |
|
|
72
|
+
| `@adroit-app/chat-tauri` | the Chat's connection to the `adroit-chat` Tauri plugin | [](https://www.npmjs.com/package/@adroit-app/chat-tauri) |
|
|
73
|
+
| `@adroit-app/session-start` | the `<adroit-session-start>` form a session starts from | [](https://www.npmjs.com/package/@adroit-app/session-start) |
|
|
74
|
+
| `adroit-chat` | the library and Tauri plugin another Tauri app embeds the Chat with, its page built in | [](https://crates.io/crates/adroit-chat) |
|
|
75
|
+
| `@adroit-app/fake-agent` | a scripted agent for the design and the tests | no |
|
|
76
|
+
| `@adroit-app/preferences` | the window's Preferences page | no |
|
|
77
|
+
| `adroit-chat-app` | the window | the release's assets, and the Homebrew cask |
|
|
78
|
+
|
|
79
|
+
The npm packages are JavaScript with declarations, and keep the Vite asset
|
|
80
|
+
imports of their sources (`?raw`, `?url`, `?inline`), as
|
|
81
|
+
[arto-markdown](https://github.com/arto-app/arto-markdown)
|
|
82
|
+
(`@arto-app/markdown`), which renders the Chat's Markdown, does: a host
|
|
83
|
+
builds them with Vite.
|
|
84
|
+
|
|
85
|
+
Inside this repository the packages are Bun workspaces whose exports name
|
|
86
|
+
their TypeScript sources, and the crates are a Cargo workspace.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
The Storybook of main is published at
|
|
91
|
+
<https://adroit-app.github.io/adroit-chat/>.
|
|
92
|
+
|
|
93
|
+
`just storybook` opens Storybook with every scenario the fake agent plays,
|
|
94
|
+
at its end or live, in light and dark; its toolbar switches the theme and
|
|
95
|
+
its controls set the rendering policy. It serves on a local port.
|
|
96
|
+
|
|
97
|
+
`just shots` builds Storybook and takes a screenshot of every story in both
|
|
98
|
+
themes into `dist/shots/`, from the build opened from disk, without a port.
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
Enter the development shell with `nix develop` (or
|
|
103
|
+
copy `.envrc.sample` to `.envrc` and `direnv allow`), which carries Bun,
|
|
104
|
+
Node, Rust and, on Linux, the libraries Tauri builds against, and:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
just install # the dependencies bun.lock pins
|
|
108
|
+
just fmt # format every source
|
|
109
|
+
just check # format check, lint, types, unit tests (TS and Rust), Storybook build,
|
|
110
|
+
# the packages as a release publishes them, the version stamp, the workflows
|
|
111
|
+
just ci # all of the above, and every story played in Chromium
|
|
112
|
+
just ci-vm # the web half of `just ci` and the screenshot comparison, in a vitro VM
|
|
113
|
+
just ui # build the Chat's page the adroit-chat crate embeds
|
|
114
|
+
just package # the npm packages staged into dist/npm, and the crate's package, checked
|
|
115
|
+
just build # the bundled app, into target/release/bundle
|
|
116
|
+
just bundle # what a release attaches for this platform, into dist/ (after `just ui`)
|
|
117
|
+
just run -- claude # the app from source
|
|
118
|
+
just run -- codex # the same with Codex
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The stories run in Chromium through a local port, so on a workstation they
|
|
122
|
+
run in a throwaway vitro VM (`just ci-vm`). The screenshots they are
|
|
123
|
+
compared with are taken there, in vitro's `linux` image, and only compare in
|
|
124
|
+
that image.
|
|
125
|
+
|
|
126
|
+
### Releasing
|
|
127
|
+
|
|
128
|
+
Write the notes and publish a GitHub release with a new tag `vX.Y.Z` on
|
|
129
|
+
main. The release workflow stamps that version over the manifests' `0.0.0`,
|
|
130
|
+
then publishes the `adroit-chat` crate, with the Chat's page built in, to
|
|
131
|
+
crates.io, and the npm packages to npm, their `workspace:` dependencies
|
|
132
|
+
pinned to the same version. Both go through trusted publishing; no token is
|
|
133
|
+
stored. It also bundles the window for each platform, outside Nix, signs the
|
|
134
|
+
macOS app by the identity "lambdalisue Release" (from the organization's
|
|
135
|
+
secrets `MACOS_SIGNING_P12` and `MACOS_SIGNING_PASSWORD`), attaches the
|
|
136
|
+
bundles and their checksums to the release, and dispatches to
|
|
137
|
+
[adroit-app/homebrew-tap](https://github.com/adroit-app/homebrew-tap), which
|
|
138
|
+
moves `Casks/adroit-chat.rb` to the disk image. CI bundles the same way on
|
|
139
|
+
every pull request, signed ad hoc. Nothing is committed for a release: the
|
|
140
|
+
tag is the only record of the version.
|
|
141
|
+
|
|
142
|
+
Dependabot keeps the crates, the Bun packages and the actions current,
|
|
143
|
+
except `agent-client-protocol` and `playwright`, which move by hand; a weekly
|
|
144
|
+
workflow does the same for `flake.lock`.
|
|
145
|
+
|
|
146
|
+
The design lives in [docs/concept.md](docs/concept.md), the decisions behind it
|
|
147
|
+
in [docs/adr/](docs/adr/), and the behaviour it promises in
|
|
148
|
+
[docs/spec/](docs/spec/).
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT. See [LICENSE](LICENSE).
|
package/dist/attach.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Base64 of `bytes`, in chunks a call's arguments can hold. */
|
|
2
|
+
export declare function base64Of(bytes: Uint8Array): string;
|
|
3
|
+
/** The bytes of base64 `data`. */
|
|
4
|
+
export declare function bytesOf(data: string): Uint8Array<ArrayBuffer>;
|
|
5
|
+
/**
|
|
6
|
+
* `file` as it is sent: its own bytes when it fits within `max` pixels on
|
|
7
|
+
* its longer side, otherwise drawn smaller, a GIF as PNG since a canvas
|
|
8
|
+
* cannot write GIF.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readImage(file: Blob, max: number): Promise<{
|
|
11
|
+
data: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
size: number;
|
|
14
|
+
}>;
|
|
15
|
+
/** The image files a drag or a paste carries. */
|
|
16
|
+
export declare function filesOf(transfer: DataTransfer | null): File[];
|
|
17
|
+
/** Whether a drag carries files at all, which can be told before it is dropped. */
|
|
18
|
+
export declare function dragsFiles(transfer: DataTransfer | null): boolean;
|
package/dist/attach.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { fitWithin } from "@adroit-app/chat-core";
|
|
2
|
+
/** Base64 of `bytes`, in chunks a call's arguments can hold. */
|
|
3
|
+
export function base64Of(bytes) {
|
|
4
|
+
let binary = "";
|
|
5
|
+
for (let at = 0; at < bytes.length; at += 0x8000) {
|
|
6
|
+
binary += String.fromCharCode(...bytes.subarray(at, at + 0x8000));
|
|
7
|
+
}
|
|
8
|
+
return btoa(binary);
|
|
9
|
+
}
|
|
10
|
+
/** The bytes of base64 `data`. */
|
|
11
|
+
export function bytesOf(data) {
|
|
12
|
+
const binary = atob(data);
|
|
13
|
+
const bytes = new Uint8Array(binary.length);
|
|
14
|
+
for (let at = 0; at < binary.length; at++)
|
|
15
|
+
bytes[at] = binary.charCodeAt(at);
|
|
16
|
+
return bytes;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `file` as it is sent: its own bytes when it fits within `max` pixels on
|
|
20
|
+
* its longer side, otherwise drawn smaller, a GIF as PNG since a canvas
|
|
21
|
+
* cannot write GIF.
|
|
22
|
+
*/
|
|
23
|
+
export async function readImage(file, max) {
|
|
24
|
+
const bitmap = await createImageBitmap(file);
|
|
25
|
+
const fit = fitWithin(bitmap.width, bitmap.height, max);
|
|
26
|
+
if (!fit.scaled) {
|
|
27
|
+
bitmap.close();
|
|
28
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
29
|
+
return { data: base64Of(bytes), mimeType: file.type, size: bytes.length };
|
|
30
|
+
}
|
|
31
|
+
const canvas = document.createElement("canvas");
|
|
32
|
+
canvas.width = fit.width;
|
|
33
|
+
canvas.height = fit.height;
|
|
34
|
+
canvas.getContext("2d")?.drawImage(bitmap, 0, 0, fit.width, fit.height);
|
|
35
|
+
bitmap.close();
|
|
36
|
+
const mimeType = file.type === "image/gif" ? "image/png" : file.type;
|
|
37
|
+
const blob = await new Promise((resolve) => canvas.toBlob(resolve, mimeType, 0.9));
|
|
38
|
+
if (!blob)
|
|
39
|
+
throw new Error("the image could not be drawn smaller");
|
|
40
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
41
|
+
return { data: base64Of(bytes), mimeType: blob.type || mimeType, size: bytes.length };
|
|
42
|
+
}
|
|
43
|
+
/** The image files a drag or a paste carries. */
|
|
44
|
+
export function filesOf(transfer) {
|
|
45
|
+
if (!transfer)
|
|
46
|
+
return [];
|
|
47
|
+
return [...transfer.files];
|
|
48
|
+
}
|
|
49
|
+
/** Whether a drag carries files at all, which can be told before it is dropped. */
|
|
50
|
+
export function dragsFiles(transfer) {
|
|
51
|
+
return transfer?.types.includes("Files") ?? false;
|
|
52
|
+
}
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { type AttachedImage, type AvailableCommand, type ChatConnection, ChatController, type ChatState, type CompletionItem, type CompletionProvider, type CompletionRange, type Location, type OpenImage, type SendOptions, type SignInMethod, type StartedWith } from "@adroit-app/chat-core";
|
|
2
|
+
import type { Files } from "@arto-app/markdown/wasm";
|
|
3
|
+
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
4
|
+
import { type Delivery } from "./composer.ts";
|
|
5
|
+
import { type Keymap } from "./keymap.ts";
|
|
6
|
+
import { type MarkdownPolicy } from "./markdown/render.ts";
|
|
7
|
+
import "./markdown/view.ts";
|
|
8
|
+
import type { ImageActions } from "./image-actions.ts";
|
|
9
|
+
import "./viewer.ts";
|
|
10
|
+
import { type ToolRenderer } from "./tools.ts";
|
|
11
|
+
/**
|
|
12
|
+
* The Chat: one ACP session's transcript, the asks it waits on, and a
|
|
13
|
+
* composer to prompt it. Its only input is `connection`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AdroitChat extends LitElement {
|
|
16
|
+
#private;
|
|
17
|
+
static properties: {
|
|
18
|
+
connection: {
|
|
19
|
+
attribute: boolean;
|
|
20
|
+
};
|
|
21
|
+
theme: {
|
|
22
|
+
reflect: boolean;
|
|
23
|
+
};
|
|
24
|
+
markdown: {
|
|
25
|
+
attribute: boolean;
|
|
26
|
+
};
|
|
27
|
+
toolRenderer: {
|
|
28
|
+
attribute: boolean;
|
|
29
|
+
};
|
|
30
|
+
cwd: {};
|
|
31
|
+
files: {
|
|
32
|
+
attribute: boolean;
|
|
33
|
+
};
|
|
34
|
+
imageBaseUrl: {
|
|
35
|
+
attribute: string;
|
|
36
|
+
};
|
|
37
|
+
openTools: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
attribute: string;
|
|
40
|
+
};
|
|
41
|
+
keymap: {
|
|
42
|
+
attribute: boolean;
|
|
43
|
+
};
|
|
44
|
+
foldThinking: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
attribute: string;
|
|
47
|
+
};
|
|
48
|
+
toolWrap: {
|
|
49
|
+
attribute: string;
|
|
50
|
+
};
|
|
51
|
+
openLocation: {
|
|
52
|
+
attribute: boolean;
|
|
53
|
+
};
|
|
54
|
+
openLink: {
|
|
55
|
+
attribute: boolean;
|
|
56
|
+
};
|
|
57
|
+
openLocationEnabled: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
attribute: string;
|
|
60
|
+
};
|
|
61
|
+
linkifyPaths: {
|
|
62
|
+
attribute: boolean;
|
|
63
|
+
};
|
|
64
|
+
titleEditable: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
attribute: string;
|
|
67
|
+
};
|
|
68
|
+
agent: {
|
|
69
|
+
attribute: boolean;
|
|
70
|
+
};
|
|
71
|
+
_renaming: {
|
|
72
|
+
state: boolean;
|
|
73
|
+
};
|
|
74
|
+
_localTitle: {
|
|
75
|
+
state: boolean;
|
|
76
|
+
};
|
|
77
|
+
fontScale: {
|
|
78
|
+
type: NumberConstructor;
|
|
79
|
+
attribute: string;
|
|
80
|
+
};
|
|
81
|
+
_state: {
|
|
82
|
+
state: boolean;
|
|
83
|
+
};
|
|
84
|
+
_draft: {
|
|
85
|
+
state: boolean;
|
|
86
|
+
};
|
|
87
|
+
_askIndex: {
|
|
88
|
+
state: boolean;
|
|
89
|
+
};
|
|
90
|
+
_composeInstead: {
|
|
91
|
+
state: boolean;
|
|
92
|
+
};
|
|
93
|
+
_signInStep: {
|
|
94
|
+
state: boolean;
|
|
95
|
+
};
|
|
96
|
+
_completion: {
|
|
97
|
+
state: boolean;
|
|
98
|
+
};
|
|
99
|
+
_delivery: {
|
|
100
|
+
state: boolean;
|
|
101
|
+
};
|
|
102
|
+
completionProviders: {
|
|
103
|
+
attribute: boolean;
|
|
104
|
+
};
|
|
105
|
+
terminalSignIn: {
|
|
106
|
+
attribute: boolean;
|
|
107
|
+
};
|
|
108
|
+
imageMaxDimension: {
|
|
109
|
+
type: NumberConstructor;
|
|
110
|
+
attribute: string;
|
|
111
|
+
};
|
|
112
|
+
openImage: {
|
|
113
|
+
attribute: boolean;
|
|
114
|
+
};
|
|
115
|
+
imageActions: {
|
|
116
|
+
attribute: boolean;
|
|
117
|
+
};
|
|
118
|
+
pickImages: {
|
|
119
|
+
attribute: boolean;
|
|
120
|
+
};
|
|
121
|
+
_attachments: {
|
|
122
|
+
state: boolean;
|
|
123
|
+
};
|
|
124
|
+
_rejected: {
|
|
125
|
+
state: boolean;
|
|
126
|
+
};
|
|
127
|
+
_dropping: {
|
|
128
|
+
state: boolean;
|
|
129
|
+
};
|
|
130
|
+
_lightbox: {
|
|
131
|
+
state: boolean;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
static styles: import("lit").CSSResult[];
|
|
135
|
+
/** The session the Chat shows and prompts. */
|
|
136
|
+
connection: ChatConnection | null;
|
|
137
|
+
/** `light` or `dark`; the system's when unset. */
|
|
138
|
+
theme: "light" | "dark" | undefined;
|
|
139
|
+
/** How Markdown is rendered, over the safe defaults (`SAFE_MARKDOWN`). */
|
|
140
|
+
markdown: Partial<MarkdownPolicy>;
|
|
141
|
+
/** How each tool call's input and output are drawn, over the defaults. */
|
|
142
|
+
toolRenderer: ToolRenderer | null;
|
|
143
|
+
/** The directory the agent works in, which relative paths in its Markdown start from. */
|
|
144
|
+
cwd: string | null;
|
|
145
|
+
/** The host's files, for a policy that lets local images be read. */
|
|
146
|
+
files: Files | null;
|
|
147
|
+
/** Where the host serves local images, for a policy that defers them. */
|
|
148
|
+
imageBaseUrl: string | null;
|
|
149
|
+
/** Tool calls start opened, each closing on a click, as for a review of what was run. */
|
|
150
|
+
openTools: boolean;
|
|
151
|
+
/** The composer's keys, over the default (`defaultKeymap`): each action named takes its keys from here. */
|
|
152
|
+
keymap: Partial<Keymap> | null;
|
|
153
|
+
/** Thinking starts folded to its header, each opening on a click. */
|
|
154
|
+
foldThinking: boolean;
|
|
155
|
+
/** How long lines in a tool call's box start: `wrap` (the default) or `scroll`; each section can switch. */
|
|
156
|
+
toolWrap: "wrap" | "scroll";
|
|
157
|
+
/**
|
|
158
|
+
* Opens a file the user clicked: true, or `preventDefault` on the
|
|
159
|
+
* `open-location` event, says it was. The Chat never opens files itself.
|
|
160
|
+
*/
|
|
161
|
+
openLocation: ((location: OpenLocation) => boolean | undefined) | null;
|
|
162
|
+
/** Opens a web or mail link the user clicked, as `openLocation` does files. */
|
|
163
|
+
openLink: ((url: string) => boolean | undefined) | null;
|
|
164
|
+
/** A listener of `open-location` opens files: paths are drawn as links. */
|
|
165
|
+
openLocationEnabled: boolean;
|
|
166
|
+
/** Inline code in replies that names a file under the session's folder opens it. */
|
|
167
|
+
linkifyPaths: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* How large the Chat draws its text, and the spacing that goes with it: 1
|
|
170
|
+
* as designed. Unset, the page's `--adroit-chat-font-scale` says, if it does.
|
|
171
|
+
*/
|
|
172
|
+
fontScale: number | null;
|
|
173
|
+
/** The session's title can be renamed from the header. */
|
|
174
|
+
titleEditable: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The agent the host runs, named for the header, with the model and mode
|
|
177
|
+
* it started it with; what the agent itself reports of its settings
|
|
178
|
+
* stands over those.
|
|
179
|
+
*/
|
|
180
|
+
agent: ({
|
|
181
|
+
name: string;
|
|
182
|
+
} & StartedWith) | null;
|
|
183
|
+
/** The header's title is a text field, being renamed. */
|
|
184
|
+
_renaming: boolean;
|
|
185
|
+
/** The name the user gave the session here, until the agent reports a title after it. */
|
|
186
|
+
_localTitle: string | null;
|
|
187
|
+
_state: ChatState | null;
|
|
188
|
+
_draft: string;
|
|
189
|
+
/** Which of the open asks is shown, when there are several. */
|
|
190
|
+
_askIndex: number;
|
|
191
|
+
/** The composer is shown though the agent waits on an answer. */
|
|
192
|
+
_composeInstead: boolean;
|
|
193
|
+
/** The completion the caret is in: where, what came, which is chosen. */
|
|
194
|
+
/** When the next prompt is sent, as the composer's toolbar chose. */
|
|
195
|
+
_delivery: Delivery;
|
|
196
|
+
_completion: {
|
|
197
|
+
range: CompletionRange;
|
|
198
|
+
items: CompletionItem[];
|
|
199
|
+
selected: number;
|
|
200
|
+
loading: boolean;
|
|
201
|
+
/** The list is the agent's `/` commands, the Chat's own provider. */
|
|
202
|
+
commands: boolean;
|
|
203
|
+
} | null;
|
|
204
|
+
/**
|
|
205
|
+
* The host's completions, after the Chat's own for the agent's `/`
|
|
206
|
+
* commands: what follows each provider's trigger is completed from what it
|
|
207
|
+
* answers. The Chat reads no files itself; paths come from a provider.
|
|
208
|
+
*/
|
|
209
|
+
completionProviders: CompletionProvider[];
|
|
210
|
+
/** A terminal sign-in the user started, waiting for them to finish it. */
|
|
211
|
+
_signInStep: {
|
|
212
|
+
method: SignInMethod;
|
|
213
|
+
command: string | null;
|
|
214
|
+
} | null;
|
|
215
|
+
/**
|
|
216
|
+
* Runs a terminal sign-in method for the user, as in a terminal it opens;
|
|
217
|
+
* resolves with the command for the user to run themselves when it could
|
|
218
|
+
* not, or null when it did. Without one, the Chat shows the method's
|
|
219
|
+
* arguments to run.
|
|
220
|
+
*/
|
|
221
|
+
terminalSignIn: ((method: SignInMethod) => Promise<string | null>) | null;
|
|
222
|
+
/** The longest side, in pixels, an attached image is scaled down to before it is sent. */
|
|
223
|
+
imageMaxDimension: number;
|
|
224
|
+
/**
|
|
225
|
+
* Shows an image the user clicked on its own: true, or `preventDefault` on
|
|
226
|
+
* the `open-image` event, says it was. Unhandled, the Chat shows it over
|
|
227
|
+
* itself.
|
|
228
|
+
*/
|
|
229
|
+
openImage: ((image: OpenImage) => boolean | undefined) | null;
|
|
230
|
+
/** What the host does with an image the Chat shows over itself: open, reveal, copy, share. */
|
|
231
|
+
imageActions: ImageActions | null;
|
|
232
|
+
/** Lets the user choose images, as the host's own file dialog; a file input without one. */
|
|
233
|
+
pickImages: (() => Promise<Array<Blob | {
|
|
234
|
+
refused: string;
|
|
235
|
+
}>>) | null;
|
|
236
|
+
_attachments: AttachedImage[];
|
|
237
|
+
/** Files that could not be attached, and why, until the user dismisses them. */
|
|
238
|
+
_rejected: Array<{
|
|
239
|
+
id: string;
|
|
240
|
+
text: string;
|
|
241
|
+
}>;
|
|
242
|
+
/** Files are dragged over the Chat. */
|
|
243
|
+
_dropping: boolean;
|
|
244
|
+
/** The image shown over the Chat, when the host does not open it. */
|
|
245
|
+
_lightbox: OpenImage | null;
|
|
246
|
+
constructor();
|
|
247
|
+
/**
|
|
248
|
+
* What the provider for `trigger` completes `query` with: the same
|
|
249
|
+
* providers the composer uses, for a host's own input to show its own way.
|
|
250
|
+
*/
|
|
251
|
+
complete(trigger: string, query: string, signal?: AbortSignal): Promise<CompletionItem[]>;
|
|
252
|
+
/** The controller of the session shown; none before a connection is set. */
|
|
253
|
+
get controller(): ChatController | null;
|
|
254
|
+
/**
|
|
255
|
+
* Sends `text`, with any images, as a prompt, as the composer does.
|
|
256
|
+
* Delivered with `steer`, it stops the work running and runs first when
|
|
257
|
+
* `canSteer`; otherwise the agent takes it in when it can.
|
|
258
|
+
*/
|
|
259
|
+
send(text: string, options?: SendOptions): void;
|
|
260
|
+
/** Stops the work running, as the stop key does in the Chat. */
|
|
261
|
+
/** The agent takes images with a prompt (ACP's prompt capabilities): images can be attached. */
|
|
262
|
+
get imagesAllowed(): boolean;
|
|
263
|
+
/** The images attached to the next prompt, in the order attached. */
|
|
264
|
+
get attachments(): readonly AttachedImage[];
|
|
265
|
+
/**
|
|
266
|
+
* Attaches `files` to the next prompt: each image scaled down to
|
|
267
|
+
* `imageMaxDimension`; a file that is no image the agent takes, or any
|
|
268
|
+
* file while the agent takes none, is listed as refused instead. A host that read
|
|
269
|
+
* a file and could not take it passes `{ refused }` with why.
|
|
270
|
+
*/
|
|
271
|
+
attach(files: Iterable<Blob | {
|
|
272
|
+
refused: string;
|
|
273
|
+
}>): Promise<void>;
|
|
274
|
+
/** Takes the attached image `id` off the next prompt. */
|
|
275
|
+
removeAttachment(id: string): void;
|
|
276
|
+
/** Takes every attached image off the next prompt, and the refusals with them. */
|
|
277
|
+
clearAttachments(): void;
|
|
278
|
+
stop(): void;
|
|
279
|
+
/** The keys in effect: `keymap` over the default, for a host's own input to read too. */
|
|
280
|
+
get effectiveKeymap(): Keymap;
|
|
281
|
+
/** The agent is working in the foreground, or waiting on the user. */
|
|
282
|
+
get working(): boolean;
|
|
283
|
+
/** A prompt sent now with `delivery: "steer"` stops the work running and runs first. */
|
|
284
|
+
get canSteer(): boolean;
|
|
285
|
+
/** How many asks the agent waits on the user's answer to. */
|
|
286
|
+
get openAsks(): number;
|
|
287
|
+
/** An ask is shown in the composer's place, waiting for the user's answer. */
|
|
288
|
+
get asking(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* The session's title as the header shows it: the name given here, the
|
|
291
|
+
* agent's, the first prompt's first line, or "New session".
|
|
292
|
+
*/
|
|
293
|
+
get sessionTitle(): string;
|
|
294
|
+
/**
|
|
295
|
+
* Renames the session to `title`: through the agent (`session/set_title`)
|
|
296
|
+
* when it can; otherwise a cancelable `rename-session` event tells the
|
|
297
|
+
* host, which may keep the name itself. The header shows the name either
|
|
298
|
+
* way, until the agent reports a title after it.
|
|
299
|
+
*/
|
|
300
|
+
rename(title: string): Promise<void>;
|
|
301
|
+
/** Shows the composer though the agent waits on an answer, or the ask again. */
|
|
302
|
+
composeInstead(compose?: boolean): void;
|
|
303
|
+
/** The slash commands the agent offers. */
|
|
304
|
+
get commands(): AvailableCommand[];
|
|
305
|
+
/**
|
|
306
|
+
* Moves focus to the input: the ask shown in the composer's place, or else
|
|
307
|
+
* the element in the `composer` slot, or the Chat's own composer.
|
|
308
|
+
*/
|
|
309
|
+
focusInput(): void;
|
|
310
|
+
/** Moves focus to the transcript, where the keys scroll it and answer asks. */
|
|
311
|
+
focusTranscript(): void;
|
|
312
|
+
/** Scrolls the transcript to its start, as a reader going back up does. */
|
|
313
|
+
scrollToStart(): void;
|
|
314
|
+
connectedCallback(): void;
|
|
315
|
+
disconnectedCallback(): void;
|
|
316
|
+
protected firstUpdated(): void;
|
|
317
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
318
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
319
|
+
protected render(): TemplateResult;
|
|
320
|
+
}
|
|
321
|
+
/** A file the user clicked in the Chat, for the host to open. */
|
|
322
|
+
export interface OpenLocation extends Location {
|
|
323
|
+
source: "tool" | "diff" | "mention" | "link" | "code";
|
|
324
|
+
toolCallId?: string;
|
|
325
|
+
}
|
|
326
|
+
declare global {
|
|
327
|
+
interface HTMLElementTagNameMap {
|
|
328
|
+
"adroit-chat": AdroitChat;
|
|
329
|
+
}
|
|
330
|
+
}
|