@adroit-app/chat-tauri 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/connection.d.ts +148 -0
- package/dist/connection.js +249 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/settings.d.ts +30 -0
- package/dist/settings.js +34 -0
- package/dist/v2.d.ts +13 -0
- package/dist/v2.js +162 -0
- package/package.json +26 -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).
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { CompletionProvider, AuthStatus, HeldPrompt, OpenImage, SignInMethod, V1, V1Connection } from "@adroit-app/chat-core";
|
|
2
|
+
/** The session the Rust side opened, as its `session` command gives it. */
|
|
3
|
+
export interface SessionInfo {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
/** The agent's name and title, as it introduced itself. */
|
|
7
|
+
agent: {
|
|
8
|
+
name?: string;
|
|
9
|
+
title?: string | null;
|
|
10
|
+
} | null;
|
|
11
|
+
/** The agent side is acp-adapter's, with its held-prompt extensions. */
|
|
12
|
+
extensions: boolean;
|
|
13
|
+
/** What the host passes on to the page, such as the user's settings. */
|
|
14
|
+
settings?: Record<string, unknown> | null;
|
|
15
|
+
/** How the host names the agent, for the window's title and the Chat's header. */
|
|
16
|
+
label?: string;
|
|
17
|
+
/** The model and mode the host started the agent with, when it chose them. */
|
|
18
|
+
model?: string | null;
|
|
19
|
+
mode?: string | null;
|
|
20
|
+
/** The session's config options, as the response that opened it gave them. */
|
|
21
|
+
configOptions?: unknown[] | null;
|
|
22
|
+
/** The session's modes (ACP v1), as the response that opened it gave them. */
|
|
23
|
+
modes?: unknown;
|
|
24
|
+
/** The session could not open until the user signs in; `sessionId` is empty until then. */
|
|
25
|
+
signInRequired?: boolean;
|
|
26
|
+
/** Prompts may carry images, as the agent said in its prompt capabilities. */
|
|
27
|
+
images?: boolean;
|
|
28
|
+
/** The session can be renamed, as the agent said. */
|
|
29
|
+
canSetTitle?: boolean;
|
|
30
|
+
/** The ways to sign in the agent offers (ACP's `authMethods`). */
|
|
31
|
+
authMethods?: SignInMethod[];
|
|
32
|
+
/** The ACP version the agent speaks to the Chat: 2, or 1 for an agent that speaks only v1. */
|
|
33
|
+
protocol?: number;
|
|
34
|
+
/** What acp-adapter says of the ACP it speaks: its protocols, v2 revision and SDK. */
|
|
35
|
+
acp?: {
|
|
36
|
+
protocols?: number[];
|
|
37
|
+
v2Revision?: string;
|
|
38
|
+
sdk?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
}
|
|
41
|
+
/** A message from the Rust side, as `adroit_chat::bridge::ToUi` writes it. */
|
|
42
|
+
export type ToUi = {
|
|
43
|
+
type: "sessionUpdate";
|
|
44
|
+
notification: V1.SessionNotification;
|
|
45
|
+
} | {
|
|
46
|
+
type: "requestPermission";
|
|
47
|
+
id: number;
|
|
48
|
+
request: V1.RequestPermissionRequest;
|
|
49
|
+
} | {
|
|
50
|
+
type: "createElicitation";
|
|
51
|
+
id: number;
|
|
52
|
+
request: V1.CreateElicitationRequest;
|
|
53
|
+
} | {
|
|
54
|
+
type: "queueChanged";
|
|
55
|
+
sessionId: string;
|
|
56
|
+
prompts: HeldPrompt[];
|
|
57
|
+
} | {
|
|
58
|
+
type: "authStatus";
|
|
59
|
+
status: AuthStatus;
|
|
60
|
+
} | {
|
|
61
|
+
type: "closed";
|
|
62
|
+
error: string | null;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Signing in may open a session, which can speak before the sign-in ends
|
|
66
|
+
* and before its own Chat connects to hear it. What it says meanwhile is
|
|
67
|
+
* held, and given to that Chat when it connects. What the connection says
|
|
68
|
+
* of itself, such as that it closed, is for both Chats: it goes on to the
|
|
69
|
+
* Chat connected now and is also kept, in order, for the opening one.
|
|
70
|
+
*/
|
|
71
|
+
export declare class Reopening {
|
|
72
|
+
#private;
|
|
73
|
+
/** Starts holding what any session but `old`, the one signing in from, says. */
|
|
74
|
+
begin(old: string): void;
|
|
75
|
+
/** Keeps `message` for the opening session: true when it is not to be given now. */
|
|
76
|
+
hold(message: ToUi): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Stops holding; what was kept, in the order it came: all of it for the
|
|
79
|
+
* opening session's Chat, or only what was not given for the Chat
|
|
80
|
+
* connected now.
|
|
81
|
+
*/
|
|
82
|
+
release(to: "opened" | "current"): ToUi[];
|
|
83
|
+
}
|
|
84
|
+
/** How the page reaches the Rust side: its commands, and the messages it sends. */
|
|
85
|
+
export interface Transport {
|
|
86
|
+
invoke<T>(command: string, args?: Record<string, unknown>): Promise<T>;
|
|
87
|
+
/** Starts the messages, the held ones first. */
|
|
88
|
+
listen(onMessage: (message: ToUi) => void): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
/** The `adroit-chat` Tauri plugin's commands and channel. */
|
|
91
|
+
export declare function pluginTransport(): Transport;
|
|
92
|
+
/**
|
|
93
|
+
* The session the Rust side runs, as an ACP v1 connection for `fromV1`.
|
|
94
|
+
* Messages that come while no client is connected are dropped; the Rust side
|
|
95
|
+
* holds them until the page listens, which happens on the first `connect`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function tauriConnection(transport?: Transport, options?: {
|
|
98
|
+
/** A session opened by signing in, with its own connection for the page to show. */
|
|
99
|
+
onReopen?: (connection: V1Connection, info: SessionInfo) => void;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
connection: V1Connection;
|
|
102
|
+
info: SessionInfo;
|
|
103
|
+
}>;
|
|
104
|
+
/** When `@` offers names starting with a dot: once one is typed, or with the rest. */
|
|
105
|
+
export type HiddenFiles = "typed" | "always";
|
|
106
|
+
/**
|
|
107
|
+
* `@` path completion over the session's folder, listed by the Rust side,
|
|
108
|
+
* which leaves out what Git ignores, and names starting with a dot as
|
|
109
|
+
* `hidden` says. A stale query's answer is dropped.
|
|
110
|
+
*/
|
|
111
|
+
export declare function pathProvider(transport?: Transport, { hidden }?: {
|
|
112
|
+
hidden?: HiddenFiles;
|
|
113
|
+
}): CompletionProvider;
|
|
114
|
+
/** Opening what the user clicks with the system, through the Rust side: files in their app, links in the browser. */
|
|
115
|
+
export declare function systemOpener(transport?: Transport): {
|
|
116
|
+
openFile(path: string): Promise<void>;
|
|
117
|
+
openLink(url: string): Promise<void>;
|
|
118
|
+
};
|
|
119
|
+
/** A host's `terminalSignIn` for the Chat: the Rust side runs the method in a terminal. */
|
|
120
|
+
export declare function terminalSignIn(transport?: Transport): (method: SignInMethod) => Promise<string | null>;
|
|
121
|
+
/**
|
|
122
|
+
* A `pickImages` for the Chat: the system's file dialog, through the Rust
|
|
123
|
+
|
|
124
|
+
* side, and why each file it could not read was refused, for the Chat to list.
|
|
125
|
+
*/
|
|
126
|
+
export declare function imagePicker(transport?: Transport): () => Promise<Array<File | {
|
|
127
|
+
refused: string;
|
|
128
|
+
}>>;
|
|
129
|
+
/** Opens an image the user clicked in a window of its own, through the Rust side. */
|
|
130
|
+
export declare function imageWindow(transport?: Transport): (image: Record<string, unknown>) => Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* What the system does with an image the Chat shows on its own (a host's
|
|
133
|
+
* `ImageActions` for `<adroit-chat>` and `<adroit-image-viewer>`): opens it
|
|
134
|
+
* in its app, shows it in the file manager, offers it to the share sheet
|
|
135
|
+
* where the system has one, and copies it or its path. The Rust side keeps
|
|
136
|
+
* an image with no file of its own in the app's cache first.
|
|
137
|
+
*/
|
|
138
|
+
export declare function systemImageActions(transport?: Transport): Promise<{
|
|
139
|
+
openWithApp(image: OpenImage): Promise<void>;
|
|
140
|
+
reveal(image: OpenImage): Promise<void>;
|
|
141
|
+
share?(image: OpenImage, anchor: DOMRect): Promise<void>;
|
|
142
|
+
copyImage(pixels: {
|
|
143
|
+
width: number;
|
|
144
|
+
height: number;
|
|
145
|
+
rgba: Uint8ClampedArray;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
copyText(text: string): Promise<void>;
|
|
148
|
+
}>;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Channel, invoke } from "@tauri-apps/api/core";
|
|
2
|
+
/** The session a message is about; none for one about the connection. */
|
|
3
|
+
function sessionOf(message) {
|
|
4
|
+
switch (message.type) {
|
|
5
|
+
case "sessionUpdate":
|
|
6
|
+
return message.notification.sessionId;
|
|
7
|
+
case "requestPermission":
|
|
8
|
+
case "createElicitation":
|
|
9
|
+
return message.request.sessionId;
|
|
10
|
+
case "queueChanged":
|
|
11
|
+
return message.sessionId;
|
|
12
|
+
case "authStatus":
|
|
13
|
+
case "closed":
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Signing in may open a session, which can speak before the sign-in ends
|
|
19
|
+
* and before its own Chat connects to hear it. What it says meanwhile is
|
|
20
|
+
* held, and given to that Chat when it connects. What the connection says
|
|
21
|
+
* of itself, such as that it closed, is for both Chats: it goes on to the
|
|
22
|
+
* Chat connected now and is also kept, in order, for the opening one.
|
|
23
|
+
*/
|
|
24
|
+
export class Reopening {
|
|
25
|
+
#held = null;
|
|
26
|
+
/** Starts holding what any session but `old`, the one signing in from, says. */
|
|
27
|
+
begin(old) {
|
|
28
|
+
this.#held = { old, messages: [] };
|
|
29
|
+
}
|
|
30
|
+
/** Keeps `message` for the opening session: true when it is not to be given now. */
|
|
31
|
+
hold(message) {
|
|
32
|
+
if (!this.#held)
|
|
33
|
+
return false;
|
|
34
|
+
const id = sessionOf(message);
|
|
35
|
+
if (id === this.#held.old)
|
|
36
|
+
return false;
|
|
37
|
+
this.#held.messages.push({ message, given: id === undefined });
|
|
38
|
+
return id !== undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Stops holding; what was kept, in the order it came: all of it for the
|
|
42
|
+
* opening session's Chat, or only what was not given for the Chat
|
|
43
|
+
* connected now.
|
|
44
|
+
*/
|
|
45
|
+
release(to) {
|
|
46
|
+
const messages = this.#held?.messages ?? [];
|
|
47
|
+
this.#held = null;
|
|
48
|
+
return messages.filter((m) => to === "opened" || !m.given).map((m) => m.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** The `adroit-chat` Tauri plugin's commands and channel. */
|
|
52
|
+
export function pluginTransport() {
|
|
53
|
+
return {
|
|
54
|
+
invoke: (command, args) => invoke(`plugin:adroit-chat|${command}`, args),
|
|
55
|
+
async listen(onMessage) {
|
|
56
|
+
const channel = new Channel();
|
|
57
|
+
channel.onmessage = onMessage;
|
|
58
|
+
await invoke("plugin:adroit-chat|connect", { onMessage: channel });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The session the Rust side runs, as an ACP v1 connection for `fromV1`.
|
|
64
|
+
* Messages that come while no client is connected are dropped; the Rust side
|
|
65
|
+
* holds them until the page listens, which happens on the first `connect`.
|
|
66
|
+
*/
|
|
67
|
+
export async function tauriConnection(transport = pluginTransport(), options = {}) {
|
|
68
|
+
let info = await transport.invoke("session");
|
|
69
|
+
let client = null;
|
|
70
|
+
let listening = false;
|
|
71
|
+
const answer = (id, response) => void transport.invoke("answer", { id, response });
|
|
72
|
+
const reopening = new Reopening();
|
|
73
|
+
/** The session signing in opened has a Chat to give what it said to, once one connects. */
|
|
74
|
+
let handOver = false;
|
|
75
|
+
const receive = (message) => {
|
|
76
|
+
if (reopening.hold(message))
|
|
77
|
+
return;
|
|
78
|
+
const to = client;
|
|
79
|
+
if (!to)
|
|
80
|
+
return;
|
|
81
|
+
switch (message.type) {
|
|
82
|
+
case "sessionUpdate":
|
|
83
|
+
to.sessionUpdate(message.notification);
|
|
84
|
+
return;
|
|
85
|
+
case "requestPermission":
|
|
86
|
+
void to.requestPermission(message.request).then((response) => answer(message.id, response), () => answer(message.id, { outcome: { outcome: "cancelled" } }));
|
|
87
|
+
return;
|
|
88
|
+
case "createElicitation":
|
|
89
|
+
void to.createElicitation(message.request).then((response) => answer(message.id, response), () => answer(message.id, { action: "cancel" }));
|
|
90
|
+
return;
|
|
91
|
+
case "queueChanged":
|
|
92
|
+
to.queueChanged(message.prompts);
|
|
93
|
+
return;
|
|
94
|
+
case "authStatus":
|
|
95
|
+
to.authStatus?.(message.status);
|
|
96
|
+
return;
|
|
97
|
+
case "closed":
|
|
98
|
+
to.sessionUpdate({
|
|
99
|
+
sessionId: info.sessionId,
|
|
100
|
+
update: {
|
|
101
|
+
sessionUpdate: "notice",
|
|
102
|
+
severity: "error",
|
|
103
|
+
title: "The agent has stopped",
|
|
104
|
+
description: message.error,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
to.closed?.(message.error);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const build = (opened) => ({
|
|
112
|
+
sessionId: opened.sessionId,
|
|
113
|
+
...(opened.signInRequired ? { signInRequired: true } : {}),
|
|
114
|
+
promptCapabilities: { image: opened.images === true },
|
|
115
|
+
...(opened.configOptions
|
|
116
|
+
? { configOptions: opened.configOptions }
|
|
117
|
+
: {}),
|
|
118
|
+
...(opened.modes ? { modes: opened.modes } : {}),
|
|
119
|
+
auth: {
|
|
120
|
+
methods: opened.authMethods ?? [],
|
|
121
|
+
async authenticate(methodId) {
|
|
122
|
+
reopening.begin(info.sessionId);
|
|
123
|
+
let next;
|
|
124
|
+
try {
|
|
125
|
+
next = await transport.invoke("authenticate", { methodId });
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
for (const message of reopening.release("current"))
|
|
129
|
+
receive(message);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
if (next.sessionId === info.sessionId) {
|
|
133
|
+
for (const message of reopening.release("current"))
|
|
134
|
+
receive(message);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
info = next;
|
|
138
|
+
handOver = options.onReopen !== undefined;
|
|
139
|
+
options.onReopen?.(build(next), next);
|
|
140
|
+
if (!handOver)
|
|
141
|
+
reopening.release("opened");
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
prompt: ({ prompt, _meta }) => transport.invoke("prompt", { prompt, meta: _meta ?? null }),
|
|
145
|
+
cancel: () => transport.invoke("cancel"),
|
|
146
|
+
connect(next) {
|
|
147
|
+
client = next;
|
|
148
|
+
if (!listening) {
|
|
149
|
+
listening = true;
|
|
150
|
+
void transport.listen(receive);
|
|
151
|
+
}
|
|
152
|
+
if (handOver && opened.sessionId === info.sessionId) {
|
|
153
|
+
handOver = false;
|
|
154
|
+
for (const message of reopening.release("opened"))
|
|
155
|
+
receive(message);
|
|
156
|
+
}
|
|
157
|
+
return () => {
|
|
158
|
+
if (client === next)
|
|
159
|
+
client = null;
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
...(opened.extensions
|
|
163
|
+
? {
|
|
164
|
+
queue: {
|
|
165
|
+
remove: (promptId) => transport.invoke("queue_remove", { promptId }),
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
: {}),
|
|
169
|
+
});
|
|
170
|
+
return { connection: build(info), info };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `@` path completion over the session's folder, listed by the Rust side,
|
|
174
|
+
* which leaves out what Git ignores, and names starting with a dot as
|
|
175
|
+
* `hidden` says. A stale query's answer is dropped.
|
|
176
|
+
*/
|
|
177
|
+
export function pathProvider(transport = pluginTransport(), { hidden = "typed" } = {}) {
|
|
178
|
+
return {
|
|
179
|
+
trigger: "@",
|
|
180
|
+
async complete(query, { signal }) {
|
|
181
|
+
const items = await transport.invoke("complete_path", { query, hidden });
|
|
182
|
+
return signal.aborted ? [] : items;
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** Opening what the user clicks with the system, through the Rust side: files in their app, links in the browser. */
|
|
187
|
+
export function systemOpener(transport = pluginTransport()) {
|
|
188
|
+
return {
|
|
189
|
+
openFile: (path) => transport.invoke("open_location", { path }),
|
|
190
|
+
openLink: (url) => transport.invoke("open_link", { url }),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** A host's `terminalSignIn` for the Chat: the Rust side runs the method in a terminal. */
|
|
194
|
+
export function terminalSignIn(transport = pluginTransport()) {
|
|
195
|
+
return (method) => transport.invoke("sign_in_terminal", { methodId: method.id });
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A `pickImages` for the Chat: the system's file dialog, through the Rust
|
|
199
|
+
|
|
200
|
+
* side, and why each file it could not read was refused, for the Chat to list.
|
|
201
|
+
*/
|
|
202
|
+
export function imagePicker(transport = pluginTransport()) {
|
|
203
|
+
return async () => {
|
|
204
|
+
const picked = await transport.invoke("pick_images");
|
|
205
|
+
return [
|
|
206
|
+
...picked.images.map((image) => {
|
|
207
|
+
const bytes = Uint8Array.from(atob(image.data), (c) => c.charCodeAt(0));
|
|
208
|
+
return new File([bytes], image.name, { type: image.mimeType });
|
|
209
|
+
}),
|
|
210
|
+
...picked.refused.map((why) => ({ refused: why })),
|
|
211
|
+
];
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** Opens an image the user clicked in a window of its own, through the Rust side. */
|
|
215
|
+
export function imageWindow(transport = pluginTransport()) {
|
|
216
|
+
return (image) => transport.invoke("open_image", { image });
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* What the system does with an image the Chat shows on its own (a host's
|
|
220
|
+
* `ImageActions` for `<adroit-chat>` and `<adroit-image-viewer>`): opens it
|
|
221
|
+
* in its app, shows it in the file manager, offers it to the share sheet
|
|
222
|
+
* where the system has one, and copies it or its path. The Rust side keeps
|
|
223
|
+
* an image with no file of its own in the app's cache first.
|
|
224
|
+
*/
|
|
225
|
+
export async function systemImageActions(transport = pluginTransport()) {
|
|
226
|
+
const can = await transport.invoke("image_actions");
|
|
227
|
+
return {
|
|
228
|
+
openWithApp: (image) => transport.invoke("image_open", { image }),
|
|
229
|
+
reveal: (image) => transport.invoke("image_reveal", { image }),
|
|
230
|
+
...(can?.share
|
|
231
|
+
? {
|
|
232
|
+
share: (image, anchor) => transport.invoke("image_share", {
|
|
233
|
+
image,
|
|
234
|
+
anchor: { x: anchor.x, y: anchor.y, width: anchor.width, height: anchor.height },
|
|
235
|
+
}),
|
|
236
|
+
}
|
|
237
|
+
: {}),
|
|
238
|
+
copyImage: ({ width, height, rgba }) => transport.invoke("copy_image", { width, height, rgba: base64Of(rgba) }),
|
|
239
|
+
copyText: (text) => transport.invoke("copy_text", { text }),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/** `bytes` in base64, a chunk at a time: a large image overflows one call's arguments. */
|
|
243
|
+
function base64Of(bytes) {
|
|
244
|
+
let binary = "";
|
|
245
|
+
for (let at = 0; at < bytes.length; at += 0x8000) {
|
|
246
|
+
binary += String.fromCharCode(...bytes.subarray(at, at + 0x8000));
|
|
247
|
+
}
|
|
248
|
+
return btoa(binary);
|
|
249
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CompletionProvider } from "@adroit-app/chat-core";
|
|
2
|
+
import type { HiddenFiles } from "./connection.ts";
|
|
3
|
+
/** The event a host sends the page the user's settings by, whenever they change. */
|
|
4
|
+
export declare const SETTINGS_EVENT = "adroit-chat:settings";
|
|
5
|
+
/** What of the Chat the user's settings set. */
|
|
6
|
+
export interface SettingsTarget {
|
|
7
|
+
keymap: object | null;
|
|
8
|
+
foldThinking: boolean;
|
|
9
|
+
toolWrap: "wrap" | "scroll";
|
|
10
|
+
fontScale: number | null;
|
|
11
|
+
theme: "light" | "dark" | undefined;
|
|
12
|
+
markdown: object;
|
|
13
|
+
linkifyPaths: boolean;
|
|
14
|
+
completionProviders: CompletionProvider[];
|
|
15
|
+
imageMaxDimension: number;
|
|
16
|
+
imageBaseUrl?: string | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets the Chat as `settings` (the host's `settings.json`) say: every
|
|
20
|
+
* setting, so one taken out of the file goes back to its default. `paths`
|
|
21
|
+
* gives the `@` completion, offering hidden files as the settings say,
|
|
22
|
+
* unless they turn it off. Where `imageBaseUrl` serves local images,
|
|
23
|
+
* they show unless the settings say otherwise.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applySettings(chat: SettingsTarget, settings: Record<string, unknown>, { paths, imageBaseUrl, }?: {
|
|
26
|
+
paths?: (hidden: HiddenFiles) => CompletionProvider;
|
|
27
|
+
imageBaseUrl?: string;
|
|
28
|
+
}): void;
|
|
29
|
+
/** Calls `onChange` with the settings each time the host sends them; resolves with a way to stop. */
|
|
30
|
+
export declare function listenSettings(onChange: (settings: Record<string, unknown>) => void): Promise<() => void>;
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IMAGE_MAX_DIMENSION } from "@adroit-app/chat-core";
|
|
2
|
+
import { listen } from "@tauri-apps/api/event";
|
|
3
|
+
/** The event a host sends the page the user's settings by, whenever they change. */
|
|
4
|
+
export const SETTINGS_EVENT = "adroit-chat:settings";
|
|
5
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
/**
|
|
7
|
+
* Sets the Chat as `settings` (the host's `settings.json`) say: every
|
|
8
|
+
* setting, so one taken out of the file goes back to its default. `paths`
|
|
9
|
+
* gives the `@` completion, offering hidden files as the settings say,
|
|
10
|
+
* unless they turn it off. Where `imageBaseUrl` serves local images,
|
|
11
|
+
* they show unless the settings say otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export function applySettings(chat, settings, { paths, imageBaseUrl, } = {}) {
|
|
14
|
+
const { keymap, foldThinking, toolWrap, fontScale, theme, markdown, linkifyPaths, completion, images, } = settings;
|
|
15
|
+
chat.keymap = isObject(keymap) ? keymap : null;
|
|
16
|
+
chat.foldThinking = foldThinking === true;
|
|
17
|
+
chat.toolWrap = toolWrap === "scroll" ? "scroll" : "wrap";
|
|
18
|
+
chat.fontScale = typeof fontScale === "number" && fontScale > 0 ? fontScale : null;
|
|
19
|
+
chat.theme = theme === "light" || theme === "dark" ? theme : undefined;
|
|
20
|
+
const policy = isObject(markdown) ? markdown : {};
|
|
21
|
+
chat.markdown = imageBaseUrl ? { localImages: "defer", ...policy } : policy;
|
|
22
|
+
if (imageBaseUrl)
|
|
23
|
+
chat.imageBaseUrl = imageBaseUrl;
|
|
24
|
+
chat.linkifyPaths = linkifyPaths !== false;
|
|
25
|
+
const completing = isObject(completion) ? completion : {};
|
|
26
|
+
const hidden = completing.hiddenFiles === "always" ? "always" : "typed";
|
|
27
|
+
chat.completionProviders = paths && completing.paths !== false ? [paths(hidden)] : [];
|
|
28
|
+
const max = isObject(images) ? images.maxDimension : undefined;
|
|
29
|
+
chat.imageMaxDimension = typeof max === "number" && max > 0 ? max : IMAGE_MAX_DIMENSION;
|
|
30
|
+
}
|
|
31
|
+
/** Calls `onChange` with the settings each time the host sends them; resolves with a way to stop. */
|
|
32
|
+
export function listenSettings(onChange) {
|
|
33
|
+
return listen(SETTINGS_EVENT, (event) => onChange(event.payload ?? {}));
|
|
34
|
+
}
|
package/dist/v2.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ChatConnection } from "@adroit-app/chat-core";
|
|
2
|
+
import { type SessionInfo, type Transport } from "./connection.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The session the Rust side runs, as the Chat's `ChatConnection`: spoken to
|
|
5
|
+
* in ACP v2 when the agent speaks it, as acp-adapter does, and otherwise
|
|
6
|
+
* through `fromV1`. `onReopen` is given the session signing in opened.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tauriChat(transport?: Transport, options?: {
|
|
9
|
+
onReopen?: (connection: ChatConnection, info: SessionInfo) => void;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
connection: ChatConnection;
|
|
12
|
+
info: SessionInfo;
|
|
13
|
+
}>;
|
package/dist/v2.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { fromV1, } from "@adroit-app/chat-core";
|
|
2
|
+
import { pluginTransport, Reopening, tauriConnection, } from "./connection.js";
|
|
3
|
+
/**
|
|
4
|
+
* The session the Rust side runs, as the Chat's `ChatConnection`: spoken to
|
|
5
|
+
* in ACP v2 when the agent speaks it, as acp-adapter does, and otherwise
|
|
6
|
+
* through `fromV1`. `onReopen` is given the session signing in opened.
|
|
7
|
+
*/
|
|
8
|
+
export async function tauriChat(transport = pluginTransport(), options = {}) {
|
|
9
|
+
const info = await transport.invoke("session");
|
|
10
|
+
if (info.protocol !== 2) {
|
|
11
|
+
const v1 = await tauriConnection({ invoke: transport.invoke.bind(transport), listen: transport.listen.bind(transport) }, { onReopen: (next, opened) => options.onReopen?.(fromV1(next), opened) });
|
|
12
|
+
return { connection: fromV1(v1.connection), info: v1.info };
|
|
13
|
+
}
|
|
14
|
+
let client = null;
|
|
15
|
+
let listening = false;
|
|
16
|
+
/** Prompts sent and not yet taken in, in the order sent, with the id acp-adapter holds each under once it says. */
|
|
17
|
+
let sent = [];
|
|
18
|
+
const answer = (id, response) => void transport.invoke("answer", { id, response });
|
|
19
|
+
const reopening = new Reopening();
|
|
20
|
+
/** The session signing in opened has a Chat to give what it said to, once one connects. */
|
|
21
|
+
let handOver = false;
|
|
22
|
+
const receive = (message) => {
|
|
23
|
+
if (reopening.hold(message))
|
|
24
|
+
return;
|
|
25
|
+
if (message.type === "queueChanged") {
|
|
26
|
+
// A held prompt carries no key, and a steered one goes ahead of the
|
|
27
|
+
// others, so a new id goes to the earliest sent prompt without one
|
|
28
|
+
// that says the same; one that says what none was sent as stays unknown,
|
|
29
|
+
// as a guess could withdraw another prompt.
|
|
30
|
+
const known = new Set(sent.map((s) => s.promptId));
|
|
31
|
+
for (const held of message.prompts) {
|
|
32
|
+
if (known.has(held.promptId))
|
|
33
|
+
continue;
|
|
34
|
+
const said = canonical(held.prompt);
|
|
35
|
+
const submission = sent.find((s) => s.promptId === undefined && s.prompt === said);
|
|
36
|
+
if (submission)
|
|
37
|
+
submission.promptId = held.promptId;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const to = client;
|
|
42
|
+
if (!to)
|
|
43
|
+
return;
|
|
44
|
+
switch (message.type) {
|
|
45
|
+
case "sessionUpdate":
|
|
46
|
+
to.sessionUpdate(message.notification);
|
|
47
|
+
return;
|
|
48
|
+
case "requestPermission":
|
|
49
|
+
void to.requestPermission(message.request).then((response) => answer(message.id, response), () => answer(message.id, { outcome: { outcome: "cancelled" } }));
|
|
50
|
+
return;
|
|
51
|
+
case "createElicitation":
|
|
52
|
+
void to.createElicitation(message.request).then((response) => answer(message.id, response), () => answer(message.id, { action: "cancel" }));
|
|
53
|
+
return;
|
|
54
|
+
case "authStatus":
|
|
55
|
+
to.authStatus?.(message.status);
|
|
56
|
+
return;
|
|
57
|
+
case "closed":
|
|
58
|
+
to.sessionUpdate({
|
|
59
|
+
sessionId: current.sessionId,
|
|
60
|
+
update: {
|
|
61
|
+
sessionUpdate: "notice",
|
|
62
|
+
severity: "error",
|
|
63
|
+
title: "The agent has stopped",
|
|
64
|
+
description: message.error,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
to.closed?.(message.error);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const build = (opened) => ({
|
|
72
|
+
sessionId: opened.sessionId,
|
|
73
|
+
abilities: opened.extensions ? { steer: true, withdraw: true } : {},
|
|
74
|
+
...(opened.signInRequired ? { signInRequired: true } : {}),
|
|
75
|
+
promptCapabilities: { image: opened.images === true },
|
|
76
|
+
...(opened.configOptions
|
|
77
|
+
? { configOptions: opened.configOptions }
|
|
78
|
+
: {}),
|
|
79
|
+
...(opened.canSetTitle
|
|
80
|
+
? { setTitle: (title) => transport.invoke("set_title", { title }) }
|
|
81
|
+
: {}),
|
|
82
|
+
auth: {
|
|
83
|
+
methods: opened.authMethods ?? [],
|
|
84
|
+
async authenticate(methodId) {
|
|
85
|
+
reopening.begin(current.sessionId);
|
|
86
|
+
let next;
|
|
87
|
+
try {
|
|
88
|
+
next = await transport.invoke("authenticate", { methodId });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
for (const message of reopening.release("current"))
|
|
92
|
+
receive(message);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
if (next.sessionId === current.sessionId) {
|
|
96
|
+
for (const message of reopening.release("current"))
|
|
97
|
+
receive(message);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
current = next;
|
|
101
|
+
handOver = options.onReopen !== undefined;
|
|
102
|
+
options.onReopen?.(build(next), next);
|
|
103
|
+
if (!handOver)
|
|
104
|
+
reopening.release("opened");
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
async prompt({ prompt, idempotencyKey, steer }) {
|
|
108
|
+
const submission = {
|
|
109
|
+
key: idempotencyKey,
|
|
110
|
+
prompt: canonical(prompt),
|
|
111
|
+
};
|
|
112
|
+
sent.push(submission);
|
|
113
|
+
try {
|
|
114
|
+
return await transport.invoke("prompt", {
|
|
115
|
+
prompt,
|
|
116
|
+
idempotencyKey,
|
|
117
|
+
meta: steer ? { acpAdapter: { steer: true } } : null,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
sent = sent.filter((s) => s !== submission);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
cancel: () => transport.invoke("cancel"),
|
|
125
|
+
...(opened.extensions
|
|
126
|
+
? {
|
|
127
|
+
async withdraw(key) {
|
|
128
|
+
const promptId = sent.find((s) => s.key === key)?.promptId;
|
|
129
|
+
if (!promptId)
|
|
130
|
+
return false;
|
|
131
|
+
return transport.invoke("queue_remove", { promptId });
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
: {}),
|
|
135
|
+
connect(next) {
|
|
136
|
+
client = next;
|
|
137
|
+
if (!listening) {
|
|
138
|
+
listening = true;
|
|
139
|
+
void transport.listen(receive);
|
|
140
|
+
}
|
|
141
|
+
if (handOver && opened.sessionId === current.sessionId) {
|
|
142
|
+
handOver = false;
|
|
143
|
+
for (const message of reopening.release("opened"))
|
|
144
|
+
receive(message);
|
|
145
|
+
}
|
|
146
|
+
return () => {
|
|
147
|
+
if (client === next)
|
|
148
|
+
client = null;
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
let current = info;
|
|
153
|
+
return { connection: build(info), info };
|
|
154
|
+
}
|
|
155
|
+
/** `value` as JSON with its keys sorted and its empty fields left out, so two writings of one prompt compare equal. */
|
|
156
|
+
function canonical(value) {
|
|
157
|
+
return JSON.stringify(value, (_, v) => v !== null && typeof v === "object" && !Array.isArray(v)
|
|
158
|
+
? Object.fromEntries(Object.entries(v)
|
|
159
|
+
.filter(([, field]) => field !== null && field !== undefined)
|
|
160
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
161
|
+
: v);
|
|
162
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adroit-app/chat-tauri",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Chat's connection to the adroit-chat Tauri plugin: an ACP v1 connection for fromV1",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/adroit-app/adroit-chat.git",
|
|
9
|
+
"directory": "packages/chat-tauri"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@adroit-app/chat-core": "0.1.0",
|
|
26
|
+
"@tauri-apps/api": "^2.13.0"
|
|
27
|
+
}
|
|
28
|
+
}
|