@muthuishere/klark-hub-ui 0.0.0-stage → 0.11.10
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 +201 -0
- package/README.md +69 -2
- package/dist/chat.d.ts +23 -0
- package/dist/components/ChatRow.d.ts +15 -0
- package/dist/components/ChatView.d.ts +32 -0
- package/dist/components/ChoiceBar.d.ts +9 -0
- package/dist/components/Composer.d.ts +31 -0
- package/dist/components/Icons.d.ts +8 -0
- package/dist/components/PaneHeader.d.ts +21 -0
- package/dist/components/Sidebar.d.ts +34 -0
- package/dist/components/Terminal.d.ts +18 -0
- package/dist/components/VirtualList.d.ts +26 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1244 -0
- package/dist/index.js.map +1 -0
- package/dist/panes.d.ts +29 -0
- package/dist/sse.d.ts +16 -0
- package/dist/storage.d.ts +12 -0
- package/dist/transport.d.ts +62 -0
- package/dist/types.d.ts +106 -0
- package/dist/useChat.d.ts +23 -0
- package/dist/windowing.d.ts +16 -0
- package/package.json +46 -4
- package/style.css +197 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @muthuishere/klark-hub-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components for watching and driving coding agents (Claude Code, Codex, Devin, ...): the chat view, composer,
|
|
4
|
+
terminal and sidebar of the [klark](https://github.com/muthuishere/klark) hub. They talk to a hub through a small
|
|
5
|
+
`Transport` interface; `httpTransport` speaks klark hub's HTTP + SSE contract (`hub-go/API.md`). The Go side of
|
|
6
|
+
the same rows is `github.com/muthuishere/klark/hub-go/chat` (and `/feed`).
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
From the GitHub tag (the tag's root is the built package; nothing runs at install):
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install github:muthuishere/klark#hub-ui-v0.1.0 @xterm/xterm @xterm/addon-unicode11
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Peers: `react >= 18`, `@xterm/xterm ^6`, `@xterm/addon-unicode11` (xterm loads only when a Terminal is first shown).
|
|
17
|
+
No router: links are plain `href`s plus `onOpen` / `onNavigate` callbacks.
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { ChatView, Composer, PaneHeader, Sidebar, httpTransport, useChat, type MachineTree } from '@muthuishere/klark-hub-ui';
|
|
23
|
+
import '@muthuishere/klark-hub-ui/style.css';
|
|
24
|
+
|
|
25
|
+
const hub = httpTransport('/'); // where the hub is mounted
|
|
26
|
+
|
|
27
|
+
function Agent({ machine, pane }: { machine: string; pane: string }) {
|
|
28
|
+
const chat = useChat(hub, machine, pane);
|
|
29
|
+
return (
|
|
30
|
+
<div className="khu" style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
|
|
31
|
+
<PaneHeader title={pane} agent="claude" status={chat.blocked ? 'blocked' : ''} />
|
|
32
|
+
<ChatView items={chat.items} loading={chat.loading} error={chat.error} blocked={chat.blocked}
|
|
33
|
+
onKeys={(keys) => hub.keys(machine, pane, keys)}
|
|
34
|
+
fileHref={(path, line) => hub.fileUrl(machine, pane, path, line)} />
|
|
35
|
+
<Composer draftKey={machine + '/' + pane} onSend={(text) => hub.send(machine, pane, text)}
|
|
36
|
+
onFiles={async (files) => { for (const f of files) await hub.upload(machine, pane, f); }} />
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`Sidebar` lists `MachineTree[]` (from `transport.machines()` + `transport.tree(id)`), grouped by project folder with
|
|
43
|
+
blocked agents first: props `items`, `current`, `hrefFor`, `onOpen`, `filter`/`onFilterChange`, `store`,
|
|
44
|
+
`renderGroupExtra`, `header`, `footer`. `Terminal` (a `ref` with `write` / `reset` / `resize`) draws the pane at its own
|
|
45
|
+
geometry; pass it as the last argument of `useChat(hub, m, a, true, termRef)` to stream frames into it.
|
|
46
|
+
|
|
47
|
+
## Exports
|
|
48
|
+
|
|
49
|
+
- Transport: `Transport`, `EventHandlers`, `httpTransport(basePath, {fetch?, EventSource?, onStatus?})`, `TransportError`
|
|
50
|
+
- Components: `Sidebar`, `ChatView`, `ChatRow`, `VirtualList`, `Composer`, `Terminal`, `PaneHeader`, `ChoiceBar`, icons
|
|
51
|
+
- Hooks and helpers: `useChat`, `connectSSE`, `backoff`, `buildRows`, `mergeItems`, `pairCalls`, `phrase`, `choiceKeys`,
|
|
52
|
+
`slashMatches`, pane helpers (`displayName`, `groupRows`, `paneStatus`, ...)
|
|
53
|
+
- Storage: `Storage` (`get`/`set`), `webStorage(area?, prefix?)`, `memoryStorage()`, `defaultStorage` (localStorage)
|
|
54
|
+
- Types: `ChatItem`, `Blocked`, `ChatPayload`, `Offer`, `MachineInfo`, `PaneInfo`, `Tree`, `MachineTree`, ...
|
|
55
|
+
|
|
56
|
+
## Styling
|
|
57
|
+
|
|
58
|
+
`style.css` styles the components under any ancestor with class `khu`, with zero specificity (`:where(.khu)`), so
|
|
59
|
+
your own CSS wins. It sets no global resets and is themed only through CSS variables, each with a light fallback:
|
|
60
|
+
`--bg --fg --muted --line --hover --card --side --accent --on-accent --link --bubble --code-bg --code-head --out-bg
|
|
61
|
+
--out-fg --blocked --working --idle --ok --bad --skel --mark --mono --serif --hl-*`.
|
|
62
|
+
|
|
63
|
+
## Security
|
|
64
|
+
|
|
65
|
+
Chat `html` is rendered by the hub (markdown with raw HTML dropped, only http/https/mailto links, ANSI as classes)
|
|
66
|
+
and inserted as is. Use a Transport whose server sanitises the same way (the Go `chat` package does).
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Apache-2.0
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChatItem } from './types';
|
|
2
|
+
export interface ChatRowModel {
|
|
3
|
+
key: string;
|
|
4
|
+
kind: 'user' | 'text' | 'tools' | 'block';
|
|
5
|
+
items: ChatItem[];
|
|
6
|
+
stamp: string;
|
|
7
|
+
}
|
|
8
|
+
/** Fold the flat transcript into display rows (port of ChatRowModel.Build). */
|
|
9
|
+
export declare function buildRows(items: ChatItem[]): ChatRowModel[];
|
|
10
|
+
/** Add or replace rows by id, keeping arrival order. New ids append. */
|
|
11
|
+
export declare function mergeItems(cur: ChatItem[], incoming: ChatItem[]): ChatItem[];
|
|
12
|
+
export interface ToolCall {
|
|
13
|
+
key: string;
|
|
14
|
+
kind: 'tool' | 'thinking';
|
|
15
|
+
use?: ChatItem;
|
|
16
|
+
result?: ChatItem;
|
|
17
|
+
}
|
|
18
|
+
/** Pair each tool_use with the result that follows it; thinking stands alone. */
|
|
19
|
+
export declare function pairCalls(items: ChatItem[]): ToolCall[];
|
|
20
|
+
export declare function verb(tool: string): [string, string];
|
|
21
|
+
export declare function toolIcon(tool: string): string;
|
|
22
|
+
/** "Read 3 files · Ran 2 commands · thought" */
|
|
23
|
+
export declare function phrase(tools: string[], thinking: number): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ChatRowModel } from '../chat';
|
|
2
|
+
/** Which <details> are open, kept outside the rows so a row scrolled out of the window and back keeps its state. */
|
|
3
|
+
export declare const OpenCtx: import("react").Context<{
|
|
4
|
+
has: (k: string) => boolean;
|
|
5
|
+
set: (k: string, open: boolean) => void;
|
|
6
|
+
}>;
|
|
7
|
+
/** How a tool row links a file path (e.g. transport.fileUrl bound to the pane); without it the path is plain text. */
|
|
8
|
+
export declare const FileHrefCtx: import("react").Context<((path: string, line?: number) => string) | null>;
|
|
9
|
+
declare function ChatRowImpl({ row }: {
|
|
10
|
+
row: ChatRowModel;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export declare function stripTags(html?: string): string;
|
|
13
|
+
/** A row re-renders only when its content (stamp) changes. */
|
|
14
|
+
export declare const ChatRow: import("react").MemoExoticComponent<typeof ChatRowImpl>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Blocked, ChatItem } from '../types';
|
|
3
|
+
export interface ChatViewProps {
|
|
4
|
+
items: ChatItem[];
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
error?: string | null;
|
|
7
|
+
blocked?: Blocked | null;
|
|
8
|
+
/** working shows a "working…" line. */
|
|
9
|
+
status?: string;
|
|
10
|
+
/** Hides the choice bar and the working line. */
|
|
11
|
+
offline?: boolean;
|
|
12
|
+
/** Answer a choice menu (key names). */
|
|
13
|
+
onKeys?: (keys: string[]) => Promise<unknown> | void;
|
|
14
|
+
/** Links of file paths in tool rows (server-rendered paths come linked already). */
|
|
15
|
+
fileHref?: (path: string, line?: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* A plain left click on a link inside the chat (file paths, `a.fpath`). Return true to say it was handled
|
|
18
|
+
* (the browser's navigation is then prevented).
|
|
19
|
+
*/
|
|
20
|
+
onNavigate?: (href: string, a: HTMLAnchorElement) => boolean | void;
|
|
21
|
+
/** Search bar above the chat. */
|
|
22
|
+
searchOpen?: boolean;
|
|
23
|
+
onSearchClose?: () => void;
|
|
24
|
+
/** Below the list, above the choice bar (e.g. files the agent offered). */
|
|
25
|
+
footer?: ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ChatViewHandle {
|
|
29
|
+
scrollToBottom: () => void;
|
|
30
|
+
}
|
|
31
|
+
/** A windowed chat: rows, tool groups, a choice bar, search, "jump to latest". */
|
|
32
|
+
export declare const ChatView: import("react").ForwardRefExoticComponent<ChatViewProps & import("react").RefAttributes<ChatViewHandle>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Blocked } from '../types';
|
|
2
|
+
/** Keys that pick `key` in an arrow-selected menu: from the highlighted option, up/down then enter. Without a
|
|
3
|
+
* known highlight, the digit itself (claude, codex and agy menus all take it). */
|
|
4
|
+
export declare function choiceKeys(b: Blocked, key: string): string[];
|
|
5
|
+
/** The agent's choice menu as buttons under the last message. */
|
|
6
|
+
export declare function ChoiceBar({ blocked, onKeys }: {
|
|
7
|
+
blocked: Blocked;
|
|
8
|
+
onKeys: (keys: string[]) => Promise<unknown> | void;
|
|
9
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Storage } from '../storage';
|
|
2
|
+
/** An image the machine already stored: its name, the absolute path the agent gets, and a local preview URL. */
|
|
3
|
+
/** A command the slash popup offers. */
|
|
4
|
+
export interface SlashCommand {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Attachment {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
preview?: string;
|
|
12
|
+
}
|
|
13
|
+
interface Props {
|
|
14
|
+
/** The draft survives reloads under `draft:` + draftKey in `storage` (default localStorage). */
|
|
15
|
+
draftKey: string;
|
|
16
|
+
storage?: Storage;
|
|
17
|
+
commands?: SlashCommand[];
|
|
18
|
+
/** Shows esc / ^C keys and the terminal placeholder. */
|
|
19
|
+
terminal?: boolean;
|
|
20
|
+
attachments?: Attachment[];
|
|
21
|
+
uploading?: boolean;
|
|
22
|
+
onRemoveAttachment?: (a: Attachment) => void;
|
|
23
|
+
/** Images attached, pasted or dropped on the composer; omit to hide the attach button. */
|
|
24
|
+
onFiles?: (files: File[]) => void;
|
|
25
|
+
onSend: (text: string) => Promise<void> | void;
|
|
26
|
+
onKey?: (key: string) => void;
|
|
27
|
+
}
|
|
28
|
+
/** The slash popup lists the commands that start with what is typed, only while the text is a single "/word". */
|
|
29
|
+
export declare function slashMatches(text: string, commands: SlashCommand[]): SlashCommand[];
|
|
30
|
+
export declare function Composer({ draftKey, storage, commands, terminal, attachments, uploading, onRemoveAttachment, onFiles, onSend, onKey }: Props): import("react").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const IconSidebar: () => import("react").JSX.Element;
|
|
2
|
+
export declare const IconBack: () => import("react").JSX.Element;
|
|
3
|
+
export declare const IconMore: () => import("react").JSX.Element;
|
|
4
|
+
export declare const IconTerminal: () => import("react").JSX.Element;
|
|
5
|
+
export declare const IconChat: () => import("react").JSX.Element;
|
|
6
|
+
export declare const IconPlus: () => import("react").JSX.Element;
|
|
7
|
+
export declare const IconUp: () => import("react").JSX.Element;
|
|
8
|
+
export declare const IconFile: () => import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface PaneHeaderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
/** A small pill after the title (the session / workspace). */
|
|
6
|
+
session?: string;
|
|
7
|
+
/** working | idle | blocked | '' (drives the colour of statusText). */
|
|
8
|
+
status?: string;
|
|
9
|
+
statusText?: string;
|
|
10
|
+
/** Tooltip of the title block (the folder). */
|
|
11
|
+
cwd?: string;
|
|
12
|
+
/** Buttons before the title (sidebar toggle, back). */
|
|
13
|
+
leading?: ReactNode;
|
|
14
|
+
/** Chat/terminal toggle; omitted when onToggleView is not given. */
|
|
15
|
+
view?: 'chat' | 'terminal';
|
|
16
|
+
onToggleView?: () => void;
|
|
17
|
+
/** Buttons after the toggle (an overflow menu...). */
|
|
18
|
+
actions?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** The bar above a chat: agent badge, name, session pill, live status, terminal toggle, actions. */
|
|
21
|
+
export declare function PaneHeader({ title, agent, session, status, statusText, cwd, leading, view, onToggleView, actions }: PaneHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type MouseEvent, type ReactNode } from 'react';
|
|
2
|
+
import { type Group, type Row } from '../panes';
|
|
3
|
+
import { type Storage } from '../storage';
|
|
4
|
+
import type { MachineTree } from '../types';
|
|
5
|
+
export interface SidebarProps {
|
|
6
|
+
/** Machines and their trees (Transport.machines + tree). Offline machines are listed apart. */
|
|
7
|
+
items: MachineTree[];
|
|
8
|
+
loaded?: boolean;
|
|
9
|
+
/** The open agent, marked current. */
|
|
10
|
+
current?: {
|
|
11
|
+
machine: string;
|
|
12
|
+
pane: string;
|
|
13
|
+
};
|
|
14
|
+
/** The link of an agent (or of a machine, when pane is undefined); used as the anchor's href. */
|
|
15
|
+
hrefFor?: (machine: string, pane?: string) => string;
|
|
16
|
+
/** A plain left click on an entry (the default navigation is prevented when given). */
|
|
17
|
+
onOpen?: (machine: string, pane: string | undefined, e: MouseEvent) => void;
|
|
18
|
+
/** Controlled search text; omit to keep it inside. */
|
|
19
|
+
filter?: string;
|
|
20
|
+
onFilterChange?: (f: string) => void;
|
|
21
|
+
/** Where folded groups (`folded`) and the show-all toggle (`showall`) are remembered. Default localStorage. */
|
|
22
|
+
store?: Storage;
|
|
23
|
+
/** Extra content in a group's header (after its count). */
|
|
24
|
+
renderGroupExtra?: (g: Group) => ReactNode;
|
|
25
|
+
/** A row's second line. Default: "needs you · kind · machine · session". The "needs you" mark stays in front either way. */
|
|
26
|
+
renderSubtitle?: (r: Row) => ReactNode;
|
|
27
|
+
header?: ReactNode;
|
|
28
|
+
/** Right side of the footer (account menu, theme...). */
|
|
29
|
+
footer?: ReactNode;
|
|
30
|
+
/** Shown when there are no machines. */
|
|
31
|
+
empty?: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/** Agents grouped by project folder, needs-you first; search with ⌘K. */
|
|
34
|
+
export declare function Sidebar({ items, loaded, current, hrefFor, onOpen, filter: filterProp, onFilterChange, store, renderGroupExtra, renderSubtitle, header, footer, empty }: SidebarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface TerminalHandle {
|
|
2
|
+
write: (b: Uint8Array) => void;
|
|
3
|
+
reset: (b: Uint8Array) => void;
|
|
4
|
+
resize: (cols: number, rows: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function decodeBase64(b64: string): Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* The pane's own geometry (never fit() to the window), scaled down with CSS to the container width and
|
|
9
|
+
* scrolling sideways below a minimum scale, so TUIs keep their exact layout. xterm loads only when first shown.
|
|
10
|
+
*/
|
|
11
|
+
export interface TerminalProps {
|
|
12
|
+
cols: number;
|
|
13
|
+
rows: number;
|
|
14
|
+
visible: boolean;
|
|
15
|
+
theme?: Record<string, string>;
|
|
16
|
+
fontSize?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const Terminal: import("react").ForwardRefExoticComponent<TerminalProps & import("react").RefAttributes<TerminalHandle>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface VirtualHandle {
|
|
3
|
+
scrollToIndex: (i: number) => void;
|
|
4
|
+
scrollToBottom: () => void;
|
|
5
|
+
}
|
|
6
|
+
interface Props<T> {
|
|
7
|
+
items: T[];
|
|
8
|
+
getKey: (t: T) => string;
|
|
9
|
+
render: (t: T, index: number) => ReactNode;
|
|
10
|
+
estimate?: number;
|
|
11
|
+
overscan?: number;
|
|
12
|
+
className?: string;
|
|
13
|
+
onPinnedChange?: (pinned: boolean) => void;
|
|
14
|
+
/** Shown inside the column above the first row. */
|
|
15
|
+
header?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Windowed chat list: only rows near the viewport are in the DOM; the rest are two spacers of the exact height
|
|
19
|
+
* they would take (measured once a row has been drawn, estimated before). Stays pinned to the bottom while the
|
|
20
|
+
* reader is there, so new rows follow; scrolling up unpins.
|
|
21
|
+
*/
|
|
22
|
+
declare function VirtualListInner<T>({ items, getKey, render, estimate, overscan, className, onPinnedChange, header }: Props<T>, ref: React.Ref<VirtualHandle>): import("react").JSX.Element;
|
|
23
|
+
export declare const VirtualList: <T>(p: Props<T> & {
|
|
24
|
+
ref?: React.Ref<VirtualHandle>;
|
|
25
|
+
}) => ReturnType<typeof VirtualListInner>;
|
|
26
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { ChatItem, ItemKind, Offer, Choice, Blocked, ChatPayload, MachineInfo, Workspace, Tab, PaneInfo, Tree, MachineTree, FeedInfo } from './types';
|
|
2
|
+
export { httpTransport, TransportError, type Transport, type EventHandlers, type HttpTransportOptions } from './transport';
|
|
3
|
+
export { connectSSE, backoff, type SseOptions, type SseState } from './sse';
|
|
4
|
+
export { buildRows, mergeItems, pairCalls, phrase, verb, toolIcon, type ChatRowModel, type ToolCall } from './chat';
|
|
5
|
+
export { offsets, computeWindow, atBottom, type WindowResult } from './windowing';
|
|
6
|
+
export { agentIcon, agentKey, displayName, folderName, groupRows, isAgent, matches, paneAgent, paneCwd, paneId, paneStatus, statusRank, workspaceLabel, type Group, type Row, } from './panes';
|
|
7
|
+
export { defaultStorage, memoryStorage, webStorage, type Storage } from './storage';
|
|
8
|
+
export { useChat, type ChatData } from './useChat';
|
|
9
|
+
export { ChatRow, OpenCtx, FileHrefCtx, stripTags } from './components/ChatRow';
|
|
10
|
+
export { ChatView, type ChatViewHandle, type ChatViewProps } from './components/ChatView';
|
|
11
|
+
export { ChoiceBar, choiceKeys } from './components/ChoiceBar';
|
|
12
|
+
export { Composer, slashMatches, type Attachment, type SlashCommand } from './components/Composer';
|
|
13
|
+
export { PaneHeader, type PaneHeaderProps } from './components/PaneHeader';
|
|
14
|
+
export { Sidebar, type SidebarProps } from './components/Sidebar';
|
|
15
|
+
export { Terminal, decodeBase64, type TerminalHandle, type TerminalProps } from './components/Terminal';
|
|
16
|
+
export { VirtualList, type VirtualHandle } from './components/VirtualList';
|
|
17
|
+
export { IconBack, IconChat, IconFile, IconMore, IconPlus, IconSidebar, IconTerminal, IconUp } from './components/Icons';
|