@softov/ahpc 0.2.0 → 0.4.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/README.md +37 -6
- package/dist/src/ahp/fake.js +61 -14
- package/dist/src/ahp/live.d.ts +7 -0
- package/dist/src/ahp/live.js +156 -43
- package/dist/src/ahp/publish.js +13 -0
- package/dist/src/ahp/types.d.ts +20 -0
- package/dist/src/app.js +34 -7
- package/dist/src/blocks.d.ts +4 -74
- package/dist/src/blocks.js +10 -48
- package/dist/src/cli/main.d.ts +1 -1
- package/dist/src/cli/main.js +109 -6
- package/dist/src/connect.d.ts +2 -0
- package/dist/src/connect.js +1 -0
- package/dist/src/control.d.ts +6 -0
- package/dist/src/control.js +140 -10
- package/dist/src/flags.js +4 -1
- package/dist/src/links.d.ts +54 -0
- package/dist/src/links.js +120 -0
- package/dist/src/main.js +14 -2
- package/dist/src/mcp/http.d.ts +10 -0
- package/dist/src/mcp/http.js +110 -3
- package/dist/src/mcp/serve.d.ts +47 -9
- package/dist/src/mcp/serve.js +65 -14
- package/dist/src/mcp/stdio.d.ts +1 -0
- package/dist/src/mcp/stdio.js +7 -1
- package/dist/src/mcp/tools.d.ts +37 -2
- package/dist/src/mcp/tools.js +439 -2
- package/dist/src/resources.d.ts +13 -0
- package/dist/src/resources.js +46 -0
- package/dist/src/screens.js +95 -50
- package/dist/src/state.d.ts +42 -0
- package/dist/src/state.js +80 -1
- package/dist/src/tui.d.ts +3 -1
- package/dist/src/tui.js +29 -4
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +38 -0
- package/dist/src/view/creature.d.ts +0 -12
- package/dist/src/view/creature.js +0 -20
- package/dist/src/view/wire.d.ts +36 -0
- package/dist/src/view/wire.js +196 -0
- package/dist/src/wait.d.ts +11 -0
- package/dist/src/wait.js +15 -2
- package/dist/src/wire.d.ts +70 -0
- package/dist/src/wire.js +194 -0
- package/dist/src/wiretui.d.ts +22 -0
- package/dist/src/wiretui.js +69 -0
- package/package.json +6 -5
- package/dist/src/diff.d.ts +0 -44
- package/dist/src/diff.js +0 -111
- package/dist/src/view/bubble.d.ts +0 -75
- package/dist/src/view/bubble.js +0 -86
- package/dist/src/view/composer.d.ts +0 -64
- package/dist/src/view/composer.js +0 -192
- package/dist/src/view/controls.d.ts +0 -44
- package/dist/src/view/controls.js +0 -49
- package/dist/src/view/details.d.ts +0 -65
- package/dist/src/view/details.js +0 -65
- package/dist/src/view/filediff.d.ts +0 -29
- package/dist/src/view/filediff.js +0 -24
- package/dist/src/view/hitl.d.ts +0 -43
- package/dist/src/view/hitl.js +0 -171
- package/dist/src/view/icons.d.ts +0 -13
- package/dist/src/view/icons.js +0 -71
- package/dist/src/view/picker.d.ts +0 -42
- package/dist/src/view/picker.js +0 -71
- package/dist/src/view/sessionhead.d.ts +0 -41
- package/dist/src/view/sessionhead.js +0 -60
- package/dist/src/view/sessions.d.ts +0 -34
- package/dist/src/view/sessions.js +0 -61
- package/dist/src/view/toolcall.d.ts +0 -27
- package/dist/src/view/toolcall.js +0 -48
- package/dist/src/view/transcript.d.ts +0 -50
- package/dist/src/view/transcript.js +0 -60
package/dist/src/view/picker.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The palette, moved.
|
|
3
|
-
*
|
|
4
|
-
* A chip on the composer's control row asks one question - which harness,
|
|
5
|
-
* which model, how much it may do without asking, which workspace - and every
|
|
6
|
-
* one of those is a command with an argument. The command palette already
|
|
7
|
-
* knows how to ask about exactly that: `openAt` drills straight into an
|
|
8
|
-
* argument, `choices` may be a list, a function or a promise, an argument
|
|
9
|
-
* *without* choices is answered by typing, and `preview` shows what a
|
|
10
|
-
* highlighted value would do.
|
|
11
|
-
*
|
|
12
|
-
* So this is not a second overlay. It is the same one, anchored above the
|
|
13
|
-
* control that asked, and shown one command's question rather than the whole
|
|
14
|
-
* registry. Anything registered later - a workspace list, a thinking level, a
|
|
15
|
-
* subagent - is a command with an argument and needs nothing here.
|
|
16
|
-
*/
|
|
17
|
-
export const PICKER = 'chat.picker';
|
|
18
|
-
export function openPicker(app, options) {
|
|
19
|
-
const command = app.commands.get(options.commandId);
|
|
20
|
-
if (!command)
|
|
21
|
-
return;
|
|
22
|
-
// The chip that opened this one closes it. A control whose panel is already
|
|
23
|
-
// showing is a toggle - clicking it again to make it go away is the first
|
|
24
|
-
// thing anybody tries, and reopening it looks like the click did nothing.
|
|
25
|
-
const showing = app.layers.entries().find((entry) => entry.id === PICKER);
|
|
26
|
-
const already = showing?.node;
|
|
27
|
-
if (already?.openAt === options.commandId) {
|
|
28
|
-
app.layers.close(PICKER);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
// Closed first, so opening a second chip's panel replaces the first rather
|
|
32
|
-
// than stacking two of them with the same id.
|
|
33
|
-
app.layers.close(PICKER);
|
|
34
|
-
app.layers.open({
|
|
35
|
-
id: PICKER,
|
|
36
|
-
// Floating, not modal: there is no scrim, because the row it is asking
|
|
37
|
-
// about has to stay readable underneath it. Which value is in force is
|
|
38
|
-
// half of what makes the question answerable.
|
|
39
|
-
layer: 'floating',
|
|
40
|
-
trapFocus: true,
|
|
41
|
-
dismissOnEscape: true,
|
|
42
|
-
dismissOnOutsideClick: true,
|
|
43
|
-
// Above the chip, aligned to its left edge - so it rises out of the
|
|
44
|
-
// control rather than appearing somewhere else on the screen. A composer
|
|
45
|
-
// sits at the bottom, so `top` is the side with room.
|
|
46
|
-
position: { kind: 'anchor', targetId: options.anchorId, side: 'top', align: 'start' },
|
|
47
|
-
node: {
|
|
48
|
-
component: 'CommandPalette',
|
|
49
|
-
...(options.width !== undefined ? { width: options.width } : {}),
|
|
50
|
-
maxWidth: options.maxWidth ?? 52,
|
|
51
|
-
visibleRows: options.visibleRows ?? 6,
|
|
52
|
-
// One command, so the panel opens on its values instead of on a search
|
|
53
|
-
// box with everything in it.
|
|
54
|
-
commands: [command],
|
|
55
|
-
openAt: options.commandId,
|
|
56
|
-
...(options.descriptions ? { descriptions: options.descriptions } : {}),
|
|
57
|
-
onClose: { handler: () => app.layers.close(PICKER) },
|
|
58
|
-
},
|
|
59
|
-
// Back to the chip that asked, however it was closed.
|
|
60
|
-
//
|
|
61
|
-
// The layer's own scope restores focus when a choice is made, and does not
|
|
62
|
-
// when the panel is dismissed with escape - which strands the keyboard on
|
|
63
|
-
// a node inside a layer that is no longer there, and the next tab starts
|
|
64
|
-
// from nowhere. Saying where focus goes is cheaper than depending on which
|
|
65
|
-
// of the two paths ran.
|
|
66
|
-
// Back to the chip that asked, whichever way it was closed. The layer's
|
|
67
|
-
// own scope restores focus after a choice; a dismissal would otherwise
|
|
68
|
-
// leave the keyboard on a node that is no longer mounted.
|
|
69
|
-
onClose: () => app.focus.focus(options.anchorId),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { BoxProps, RenderOutput } from '@textui/core';
|
|
2
|
-
import type { SessionSummary } from '../ahp/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* What this conversation *is*, at the top of it.
|
|
5
|
-
*
|
|
6
|
-
* The first thing in the transcript rather than a band above it, and that is
|
|
7
|
-
* the whole design: a caption pinned outside the scrolling region costs a row
|
|
8
|
-
* of the conversation on every screen for ever, so it has to earn each one -
|
|
9
|
-
* which meant one line, which meant dropping most of what it is for. Scrolled
|
|
10
|
-
* with the conversation it costs nothing after the first screen and can say
|
|
11
|
-
* everything, the way the top of a printed letter does.
|
|
12
|
-
*
|
|
13
|
-
* The identifiers are the point. They are what gets pasted into a shell or a
|
|
14
|
-
* bug report, they are exactly what does not fit anywhere else, and the
|
|
15
|
-
* catalogue's detail pane - the only other place they appear - is a screen
|
|
16
|
-
* away from the conversation they belong to.
|
|
17
|
-
*/
|
|
18
|
-
export interface ChatSessionHeadProps extends BoxProps {
|
|
19
|
-
session: SessionSummary;
|
|
20
|
-
/** What the last turn ran on. A session has no model; each message has one. */
|
|
21
|
-
model?: string;
|
|
22
|
-
/** The chat uri, when the host has said which one this dispatches to. */
|
|
23
|
-
chat?: string | null;
|
|
24
|
-
/** The settings in force, by the host's own labels. */
|
|
25
|
-
settings?: {
|
|
26
|
-
label: string;
|
|
27
|
-
value: string;
|
|
28
|
-
}[];
|
|
29
|
-
/**
|
|
30
|
-
* Who else the host says is in this session.
|
|
31
|
-
*
|
|
32
|
-
* This client is in the list too - it adds itself on opening the view - so
|
|
33
|
-
* a session with nobody else in it has one entry and says nothing, which is
|
|
34
|
-
* the ordinary case.
|
|
35
|
-
*/
|
|
36
|
-
present?: {
|
|
37
|
-
clientId: string;
|
|
38
|
-
displayName?: string;
|
|
39
|
-
}[];
|
|
40
|
-
}
|
|
41
|
-
export declare const ChatSessionHead: (props: ChatSessionHeadProps) => RenderOutput;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@textui/core/jsx-runtime";
|
|
2
|
-
import { defineComponent, useTheme } from '@textui/core';
|
|
3
|
-
import { Column, KeyValue, Row } from '@textui/widgets';
|
|
4
|
-
import { decodeStatus } from '../ahp/status.js';
|
|
5
|
-
import { branchName } from '../state.js';
|
|
6
|
-
/**
|
|
7
|
-
* A timestamp a person can read, in whatever this machine calls a date.
|
|
8
|
-
*
|
|
9
|
-
* The host sends ISO, which is unambiguous and not what anybody wants to read
|
|
10
|
-
* off a caption. An unparseable one is passed through rather than shown as
|
|
11
|
-
* "Invalid Date": what the host said is more useful than what we made of it.
|
|
12
|
-
*/
|
|
13
|
-
function when(iso) {
|
|
14
|
-
if (!iso)
|
|
15
|
-
return '';
|
|
16
|
-
const at = new Date(iso);
|
|
17
|
-
if (Number.isNaN(at.getTime()))
|
|
18
|
-
return iso;
|
|
19
|
-
return at.toLocaleString(undefined, {
|
|
20
|
-
year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit',
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export const ChatSessionHead = defineComponent('ChatSessionHead', (props) => {
|
|
24
|
-
const { session, model, chat, settings = [], present = [], ...rest } = props;
|
|
25
|
-
const theme = useTheme();
|
|
26
|
-
const status = decodeStatus(session.status);
|
|
27
|
-
const started = when(session.createdAt);
|
|
28
|
-
const updated = when(session.modifiedAt);
|
|
29
|
-
// Only what is known. A row of empty values is what building this from a
|
|
30
|
-
// fixed list produces, and it reads as a session the host would not talk
|
|
31
|
-
// about rather than as one nobody has asked yet.
|
|
32
|
-
const rows = [
|
|
33
|
-
{ label: 'Harness', value: [session.provider, model].filter(Boolean).join(` ${theme.glyphs.separator} `) },
|
|
34
|
-
...settings.filter((setting) => setting.value).map((setting) => ({ ...setting })),
|
|
35
|
-
{ label: 'Workspace', value: session.workingDirectories.map((dir) => dir.replace(/^file:\/\//, '')).join(', ') },
|
|
36
|
-
// Only when the host says one. A blank branch row reads as a detached
|
|
37
|
-
// head rather than as a host that does not report branches.
|
|
38
|
-
...(branchName(session) ? [{ label: 'Branch', value: branchName(session) }] : []),
|
|
39
|
-
{
|
|
40
|
-
label: 'Started',
|
|
41
|
-
value: started && updated && updated !== started
|
|
42
|
-
? `${started} ${theme.glyphs.separator} updated ${updated}`
|
|
43
|
-
: started,
|
|
44
|
-
},
|
|
45
|
-
// Last, and in full. A uri you can read half of is worse than one you
|
|
46
|
-
// cannot see at all: it looks like the whole thing.
|
|
47
|
-
{ label: 'Session', value: session.resource },
|
|
48
|
-
...(chat ? [{ label: 'Chat', value: chat }] : []),
|
|
49
|
-
// Only when somebody else is here. One entry is this client, and a row
|
|
50
|
-
// saying you are the person reading it is a row that tells nobody
|
|
51
|
-
// anything.
|
|
52
|
-
...(present.length > 1
|
|
53
|
-
? [{
|
|
54
|
-
label: 'Here',
|
|
55
|
-
value: present.map((one) => one.displayName ?? one.clientId).join(` ${theme.glyphs.separator} `),
|
|
56
|
-
}]
|
|
57
|
-
: []),
|
|
58
|
-
].filter((row) => row.value !== '');
|
|
59
|
-
return (_jsxs(Column, { ...rest, gap: 0, children: [_jsxs(Row, { gap: 1, children: [_jsx("text", { content: theme.glyphs[status.glyph], fg: status.tone, shrink: 0 }), _jsx("text", { content: session.title, bold: true, wrap: "word", flex: 1 }), _jsx("text", { content: status.label, fg: status.tone, shrink: 0 })] }), _jsx(KeyValue, { items: rows })] }));
|
|
60
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { BoxProps, RenderOutput } from '@textui/core';
|
|
2
|
-
import type { SessionSummary } from '../ahp/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* The catalogue.
|
|
5
|
-
*
|
|
6
|
-
* Still a `List` - the selection, the keys, the window and the highlight are
|
|
7
|
-
* all the list's, and reimplementing them here is what the transcript already
|
|
8
|
-
* proved is a mistake. What is ours is the row, because a session does not fit
|
|
9
|
-
* the one-line shape a list gives you for free.
|
|
10
|
-
*
|
|
11
|
-
* It takes two lines, and the first one is why. A title, a harness, a
|
|
12
|
-
* workspace and a status sharing a pane that is also sharing the terminal
|
|
13
|
-
* with the detail panel leaves every one of them truncated:
|
|
14
|
-
* `Draft replies for desk-produ…` beside `1b444e78-d050-4fb5-a5…` names
|
|
15
|
-
* neither the conversation nor the directory it is in. So the title gets the
|
|
16
|
-
* width, and everything that qualifies it goes underneath.
|
|
17
|
-
*/
|
|
18
|
-
export interface SessionListProps extends BoxProps {
|
|
19
|
-
sessions: SessionSummary[];
|
|
20
|
-
selectedId?: string | null;
|
|
21
|
-
onSelect?(uri: string): void;
|
|
22
|
-
onOpen?(uri: string): void;
|
|
23
|
-
emptyMessage?: string;
|
|
24
|
-
focusId?: string;
|
|
25
|
-
autoFocus?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare const SessionList: (props: SessionListProps) => RenderOutput;
|
|
28
|
-
export interface ConnectionBadgeProps extends BoxProps {
|
|
29
|
-
url: string;
|
|
30
|
-
state: 'connecting' | 'connected' | 'offline';
|
|
31
|
-
sessions?: number;
|
|
32
|
-
}
|
|
33
|
-
/** Which host, and whether it is answering. */
|
|
34
|
-
export declare const ConnectionBadge: (props: ConnectionBadgeProps) => RenderOutput;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@textui/core/jsx-runtime";
|
|
2
|
-
import { defineComponent, stringWidth, useTheme } from '@textui/core';
|
|
3
|
-
import { Badge, Column, List, Marquee, Row } from '@textui/widgets';
|
|
4
|
-
import { decodeStatus } from '../ahp/status.js';
|
|
5
|
-
import { branchName, projectName } from '../state.js';
|
|
6
|
-
export const SessionList = defineComponent('SessionList', (props) => {
|
|
7
|
-
const { sessions, selectedId, onSelect, onOpen, emptyMessage, focusId, autoFocus, ...rest } = props;
|
|
8
|
-
const theme = useTheme();
|
|
9
|
-
const dot = ` ${theme.glyphs.separator} `;
|
|
10
|
-
const items = sessions.map((session) => {
|
|
11
|
-
const status = decodeStatus(session.status);
|
|
12
|
-
const changes = session.changes;
|
|
13
|
-
return {
|
|
14
|
-
id: session.resource,
|
|
15
|
-
// Glyph first, so the one that wants a person is findable in a piped
|
|
16
|
-
// log, a 16-colour session and by a reader who cannot see the colour.
|
|
17
|
-
icon: theme.glyphs[status.glyph],
|
|
18
|
-
label: session.title,
|
|
19
|
-
// The second line, in the order it gets read: which harness, then
|
|
20
|
-
// where, then what it has to show for it.
|
|
21
|
-
//
|
|
22
|
-
// The harness stands where a model would. The catalogue does not carry
|
|
23
|
-
// one: `listSessions` answers with a `SessionSummary`, and the model
|
|
24
|
-
// AHP knows is the one on the *last message*, which lives on the
|
|
25
|
-
// session channel. A model per row would be a subscription per row.
|
|
26
|
-
description: [
|
|
27
|
-
session.provider,
|
|
28
|
-
// The project, then the branch it is on - a catalogue spanning
|
|
29
|
-
// several repositories is read by which one each row is in, and a
|
|
30
|
-
// list of them all on `main` is a list that needs opening to tell
|
|
31
|
-
// apart.
|
|
32
|
-
[projectName(session), branchName(session)].filter(Boolean).join(' '),
|
|
33
|
-
changes?.files
|
|
34
|
-
? `${changes.files} files +${changes.additions ?? 0} -${changes.deletions ?? 0}`
|
|
35
|
-
: '',
|
|
36
|
-
// What the host says it is doing, in its own words. Last, because it
|
|
37
|
-
// is the one that is usually not there.
|
|
38
|
-
session.activity ?? '',
|
|
39
|
-
// Why it is here at all, when nobody started it. Without this a
|
|
40
|
-
// session that appeared at nine in the morning is a row with no
|
|
41
|
-
// account of itself, sitting among rows somebody typed.
|
|
42
|
-
session.origin?.kind === 'automation' ? 'by an automation' : '',
|
|
43
|
-
status.archived ? 'archived' : '',
|
|
44
|
-
].filter(Boolean).join(dot),
|
|
45
|
-
meta: status.label,
|
|
46
|
-
tone: status.tone,
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
return (_jsx(List, { items: items, itemHeight: 2, renderItem: (item, state) => (_jsxs(Column, { children: [_jsxs(Row, { gap: 1, children: [_jsx("text", { content: item.icon ?? '', ...(state.selected ? {} : { fg: item.tone }), shrink: 0 }), _jsx(Marquee, { content: item.label, active: state.selected && state.focused, flex: 1 }), _jsx("text", { content: item.meta ?? '', ...(state.selected ? {} : { fg: 'muted' }), shrink: 0 })] }), _jsxs(Row, { children: [_jsx("text", { content: ' '.repeat(stringWidth(item.icon ?? '') + 1), shrink: 0 }), _jsx(Marquee, { content: item.description ?? '', active: state.selected && state.focused, ...(state.selected ? {} : { fg: 'muted' }), flex: 1 })] })] })), ...(selectedId ? { selectedId } : {}), emptyMessage: emptyMessage ?? 'No sessions on this host', onSelect: (id) => onSelect?.(id), onActivate: (id) => onOpen?.(id), ...(focusId ? { focusId } : {}), ...(autoFocus ? { autoFocus: true } : {}), ...rest }));
|
|
50
|
-
});
|
|
51
|
-
/** Which host, and whether it is answering. */
|
|
52
|
-
export const ConnectionBadge = defineComponent('ConnectionBadge', (props) => {
|
|
53
|
-
const { url, state, sessions, ...rest } = props;
|
|
54
|
-
const theme = useTheme();
|
|
55
|
-
const look = {
|
|
56
|
-
connected: { tone: 'success', glyph: theme.glyphs.bulletFilled },
|
|
57
|
-
connecting: { tone: 'warning', glyph: theme.glyphs.bulletHalf },
|
|
58
|
-
offline: { tone: 'danger', glyph: theme.glyphs.cross },
|
|
59
|
-
}[state];
|
|
60
|
-
return (_jsxs(Row, { gap: 1, ...rest, children: [_jsx("text", { content: look.glyph, fg: look.tone }), _jsx("text", { content: url, fg: "muted", truncate: "start" }), sessions !== undefined ? _jsx(Badge, { label: `${sessions} sessions`, tone: "muted" }) : null] }));
|
|
61
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { BoxProps, RenderOutput } from '@textui/core';
|
|
2
|
-
import type { ToolCall } from '../ahp/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* A tool call, as a row.
|
|
5
|
-
*
|
|
6
|
-
* Twenty of these in a turn look identical unless the *command* is on the row,
|
|
7
|
-
* so the input is the row and the display name is a prefix. What it meant to
|
|
8
|
-
* do is markdown, like everything else a host writes for a person; what came
|
|
9
|
-
* back is not, and is shown as it arrived.
|
|
10
|
-
*
|
|
11
|
-
* The status is a glyph and a colour together. A 16-colour session, a piped
|
|
12
|
-
* log and a colourblind reader all lose the colour and keep the glyph.
|
|
13
|
-
*
|
|
14
|
-
* It sits at the turn's own left edge rather than inside the gutter, with its
|
|
15
|
-
* status glyph where the header's bullet is. A tool call is something the
|
|
16
|
-
* agent *did*; indenting it inside the rule filed it under what the agent was
|
|
17
|
-
* saying, which is the one thing it is not.
|
|
18
|
-
*/
|
|
19
|
-
export interface ToolCallRowProps extends BoxProps {
|
|
20
|
-
call: ToolCall;
|
|
21
|
-
expanded?: boolean;
|
|
22
|
-
/** The transcript's cursor is on this row. */
|
|
23
|
-
active?: boolean;
|
|
24
|
-
/** Clicking the row opens it. */
|
|
25
|
-
onToggle?(): void;
|
|
26
|
-
}
|
|
27
|
-
export declare const ToolCallRow: (props: ToolCallRowProps) => RenderOutput;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@textui/core/jsx-runtime";
|
|
2
|
-
import { defineComponent, useTheme } from '@textui/core';
|
|
3
|
-
import { Badge, Column, MarkdownView, Row } from '@textui/widgets';
|
|
4
|
-
const LOOK = {
|
|
5
|
-
pending: { tone: 'muted', glyph: 'bulletHollow' },
|
|
6
|
-
'pending-confirmation': { tone: 'warning', glyph: 'bulletHalf' },
|
|
7
|
-
running: { tone: 'accent', glyph: 'bulletFilled' },
|
|
8
|
-
completed: { tone: 'success', glyph: 'check' },
|
|
9
|
-
failed: { tone: 'danger', glyph: 'cross' },
|
|
10
|
-
cancelled: { tone: 'muted', glyph: 'cross' },
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* The input, as one line.
|
|
14
|
-
*
|
|
15
|
-
* A tool's arguments are often JSON, and JSON arrives with newlines in it. Put
|
|
16
|
-
* straight on the row, a three-line object makes the row three lines tall and
|
|
17
|
-
* every other cell in it vertically centred - so the name floats beside the
|
|
18
|
-
* middle line of a brace-delimited block. The whole thing is on its own lines
|
|
19
|
-
* once the row is opened; this is the part that fits beside a name.
|
|
20
|
-
*/
|
|
21
|
-
function oneLine(text) {
|
|
22
|
-
return text.replace(/\s+/g, ' ').trim();
|
|
23
|
-
}
|
|
24
|
-
export const ToolCallRow = defineComponent('ToolCallRow', (props) => {
|
|
25
|
-
const { call, expanded, active, onToggle, ...rest } = props;
|
|
26
|
-
const theme = useTheme();
|
|
27
|
-
const look = LOOK[call.status] ?? { tone: 'muted', glyph: 'bulletHollow' };
|
|
28
|
-
const glyph = theme.glyphs[look.glyph];
|
|
29
|
-
const chevron = expanded ? theme.glyphs.chevronDown : theme.glyphs.chevronRight;
|
|
30
|
-
const failed = call.status === 'failed' || (call.exitCode !== undefined && call.exitCode !== 0);
|
|
31
|
-
const summary = oneLine(call.input ?? call.intention ?? '');
|
|
32
|
-
// Only when there is something under it. A chevron on a row that opens on
|
|
33
|
-
// to nothing is a promise the row cannot keep.
|
|
34
|
-
const opens = Boolean(call.intention ?? call.input ?? call.output ?? call.outcome
|
|
35
|
-
?? (call.files && call.files.length > 0));
|
|
36
|
-
return (_jsxs(Column, { ...rest, ...(active ? { bg: 'selected' } : {}), children: [_jsxs(Row, { gap: 1, ...(opens && onToggle ? { onClick: onToggle } : {}),
|
|
37
|
-
// The whole row lights up, not the glyph the pointer happens to be
|
|
38
|
-
// over: the row is the thing that opens.
|
|
39
|
-
style: { hover: { bg: 'hover' } }, children: [_jsx("text", { content: glyph, fg: look.tone }), _jsx("text", { content: call.name, bold: true }), _jsx("text", { content: summary, fg: "muted", flex: 1, truncate: "middle" }), call.status === 'pending-confirmation' ? _jsx(Badge, { label: "asks", tone: "warning", icon: theme.glyphs.warning }) : null, failed ? _jsx(Badge, { label: `exit ${call.exitCode ?? 1}`, tone: "danger" }) : null, opens ? _jsx("text", { content: chevron, fg: "subtle" }) : null] }), expanded ? (
|
|
40
|
-
// Indented to the row's own text, which starts one glyph and one gap
|
|
41
|
-
// in - so what opened out of a row lines up under it.
|
|
42
|
-
_jsxs(Column, { padding: [0, 0, 0, 2], gap: 0, children: [call.intention && call.intention !== call.name && call.intention !== call.input
|
|
43
|
-
? _jsx(MarkdownView, { content: call.intention, quiet: true })
|
|
44
|
-
: null, call.input ? (
|
|
45
|
-
// On its own lines, wrapped as written. This is where the JSON
|
|
46
|
-
// goes: whole, and not sharing a row with the name.
|
|
47
|
-
_jsx(Column, { bg: "surfaceAlt", padding: [0, 1], children: call.input.split('\n').map((line, i) => (_jsx("text", { content: line, fg: "text", wrap: "word" }, i))) })) : null, call.output ? (_jsxs(Column, { children: [call.output.split('\n').slice(0, 12).map((line, i) => (_jsx("text", { content: line, fg: "muted", truncate: "end" }, i))), call.output.split('\n').length > 12 ? (_jsx("text", { content: `${theme.glyphs.ellipsis} ${call.output.split('\n').length - 12} more lines`, fg: "subtle" })) : null] })) : null, call.files && call.files.length > 0 ? (_jsx(Column, { children: call.files.map((file) => (_jsx("text", { content: `${theme.glyphs.chevronRight} ${file}`, fg: "info" }, file))) })) : null, call.outcome ? _jsx("text", { content: call.outcome, fg: "subtle" }) : null] })) : null] }));
|
|
48
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { BoxProps, RenderOutput } from '@textui/core';
|
|
2
|
-
import type { Block } from '../blocks.js';
|
|
3
|
-
/**
|
|
4
|
-
* The conversation, as blocks in a feed.
|
|
5
|
-
*
|
|
6
|
-
* There is no scrolling in this file. `Feed` owns the viewport, the cursor and
|
|
7
|
-
* the tail it follows, because none of that is about chat: a transcript, an
|
|
8
|
-
* activity stream and a list of search results with snippets are the same
|
|
9
|
-
* problem, which is "entries that are not one line tall". What is left here is
|
|
10
|
-
* the only part that *is* about chat - which block draws as what.
|
|
11
|
-
*/
|
|
12
|
-
export interface ChatTranscriptProps extends BoxProps {
|
|
13
|
-
blocks: Block[];
|
|
14
|
-
expanded: Record<string, boolean>;
|
|
15
|
-
onToggle(id: string): void;
|
|
16
|
-
/** Which block the cursor is on. Held by the screen, like every other state. */
|
|
17
|
-
cursor?: number;
|
|
18
|
-
onCursor?(index: number): void;
|
|
19
|
-
/**
|
|
20
|
-
* What the find box is looking for.
|
|
21
|
-
*
|
|
22
|
-
* Passed down to be coloured where it appears, not to decide what is drawn:
|
|
23
|
-
* every block stays where it was and the ones holding the term light up, so
|
|
24
|
-
* a reader keeps the conversation around a hit instead of a filtered list
|
|
25
|
-
* of the lines that matched.
|
|
26
|
-
*/
|
|
27
|
-
match?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Keep the cursor in view rather than only when it moves.
|
|
30
|
-
*
|
|
31
|
-
* For the find box, which drives the cursor: its first hit is often the
|
|
32
|
-
* block the cursor is already on, and a feed that only scrolls on a change
|
|
33
|
-
* would leave that one off screen while the box counted it.
|
|
34
|
-
*/
|
|
35
|
-
pinCursor?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* What this conversation is, as the first thing in it.
|
|
38
|
-
*
|
|
39
|
-
* Inside the scrolling region rather than pinned above it: a caption outside
|
|
40
|
-
* costs a row of the conversation on every screen for ever, so it has to
|
|
41
|
-
* earn each one - which is what forces it down to a line and then down to
|
|
42
|
-
* less than it was for. Here it costs nothing after the first screen.
|
|
43
|
-
*
|
|
44
|
-
* It is not a block. The cursor walks the conversation and there is nothing
|
|
45
|
-
* to do to a caption, so it sits ahead of the indices rather than in them.
|
|
46
|
-
*/
|
|
47
|
-
head?: RenderOutput;
|
|
48
|
-
focusId?: string;
|
|
49
|
-
}
|
|
50
|
-
export declare const ChatTranscript: (props: ChatTranscriptProps) => RenderOutput;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@textui/core/jsx-runtime";
|
|
2
|
-
import { defineComponent, useTheme } from '@textui/core';
|
|
3
|
-
import { Feed, Row } from '@textui/widgets';
|
|
4
|
-
import { ChatBubble, Gutter, ReasoningBlock, StreamingText } from './bubble.js';
|
|
5
|
-
import { ToolCallRow } from './toolcall.js';
|
|
6
|
-
export const ChatTranscript = defineComponent('ChatTranscript', (props) => {
|
|
7
|
-
const { blocks, expanded, onToggle, cursor, onCursor, head, match, pinCursor, focusId = 'chat.transcript', ...rest } = props;
|
|
8
|
-
// The caption is an entry the feed scrolls and the cursor does not visit,
|
|
9
|
-
// so every index the feed reports is one further along than the block it
|
|
10
|
-
// stands for. Converted here, once, rather than at each of the three
|
|
11
|
-
// places that would otherwise each have to remember.
|
|
12
|
-
const lead = head ? 1 : 0;
|
|
13
|
-
return (_jsxs(Feed, { focusId: focusId,
|
|
14
|
-
// Page up from the composer means the conversation above it. There is
|
|
15
|
-
// nothing else on this screen those keys could be for, and taking the
|
|
16
|
-
// keyboard off the field to use them is what a reader is avoiding.
|
|
17
|
-
pageKeys: "always", ...(cursor !== undefined ? { selectedIndex: cursor + lead } : {}), ...(pinCursor ? { pinSelection: true } : {}), ...(onCursor ? { onSelect: (index) => onCursor(Math.max(0, index - lead)) } : {}), onActivate: (index) => {
|
|
18
|
-
const block = blocks[index - lead];
|
|
19
|
-
if (block)
|
|
20
|
-
onToggle(block.id);
|
|
21
|
-
}, ...rest, children: [head ?? null, blocks.map((block) => (_jsx(BlockView, { block: block, expanded: expanded[block.id] ?? false, active: cursor !== undefined && blocks[cursor]?.id === block.id, ...(match ? { match } : {}), onToggle: () => onToggle(block.id) }, block.id)))] }));
|
|
22
|
-
});
|
|
23
|
-
const BlockView = defineComponent('ChatBlockView', ({ block, expanded, active, match, onToggle }) => {
|
|
24
|
-
const theme = useTheme();
|
|
25
|
-
// Spread rather than passed, so a block with no search over it carries no
|
|
26
|
-
// extra prop and its text node is compared unchanged.
|
|
27
|
-
const hit = match ? { match } : {};
|
|
28
|
-
switch (block.kind) {
|
|
29
|
-
case 'said':
|
|
30
|
-
// The blank row is the turn boundary. A uniform gap between every block
|
|
31
|
-
// would space a paragraph from the sentence it belongs to just as much
|
|
32
|
-
// as it spaces one speaker from the next.
|
|
33
|
-
return (_jsx(ChatBubble, { speaker: "user", padding: [1, 0, 0, 0], children: _jsx("text", { content: block.text, wrap: "word", ...hit }) }));
|
|
34
|
-
case 'header':
|
|
35
|
-
return (_jsxs(Row, { gap: 1, padding: [1, 0, 0, 0], children: [_jsx("text", { content: theme.glyphs.bulletFilled, fg: block.state === 'running' ? 'accent' : 'muted' }), _jsx("text", { content: block.model ?? 'agent', bold: true, fg: "accent" }), block.settings ? _jsx("text", { content: block.settings, fg: "subtle" }) : null, _jsx("text", { content: block.meta, fg: "subtle", flex: 1 }), block.state === 'cancelled' ? _jsx("text", { content: "stopped", fg: "warning" }) : null, block.state === 'failed' ? _jsx("text", { content: "failed", fg: "danger" }) : null] }));
|
|
36
|
-
case 'prose':
|
|
37
|
-
return (_jsxs(Row, { gap: 1, children: [_jsx(Gutter, {}), _jsx(StreamingText, { content: block.content, streaming: block.streaming, flex: 1, ...hit })] }));
|
|
38
|
-
case 'reasoning':
|
|
39
|
-
return (_jsxs(Row, { gap: 1, children: [_jsx(Gutter, {}), _jsx(ReasoningBlock, { content: block.content, expanded: expanded, streaming: block.streaming, flex: 1, ...hit, ...(active ? { bg: 'selected' } : {}) })] }));
|
|
40
|
-
case 'notice':
|
|
41
|
-
return (_jsxs(Row, { gap: 1, children: [_jsx("text", { content: theme.glyphs.info, fg: "info" }), _jsx("text", { content: block.content, fg: "muted", wrap: "word", flex: 1, ...hit })] }));
|
|
42
|
-
// Not a notice. A notice is the harness saying something in passing, and
|
|
43
|
-
// this is the turn stopping - so it takes the danger tone and says whether
|
|
44
|
-
// there is anything to carry on from.
|
|
45
|
-
case 'failure':
|
|
46
|
-
return (_jsxs(Row, { gap: 1, children: [_jsx("text", { content: theme.glyphs.cross, fg: "danger" }), _jsx("text", { content: block.content, fg: "danger", wrap: "word", flex: 1, ...hit }), block.resumable ? _jsx("text", { content: "resumable", fg: "subtle" }) : null] }));
|
|
47
|
-
case 'tool':
|
|
48
|
-
// No gutter. A tool call is something the agent *did*, not something it
|
|
49
|
-
// said, so it sits at the turn's own left edge with a status glyph where
|
|
50
|
-
// the header's bullet is - rather than indented inside the rule as
|
|
51
|
-
// though it were a paragraph of the answer.
|
|
52
|
-
return _jsx(ToolCallRow, { call: block.call, expanded: expanded, active: active, onToggle: onToggle });
|
|
53
|
-
case 'queued':
|
|
54
|
-
// Not sent. It reads as a message unless it says so, and "I typed that
|
|
55
|
-
// and nothing happened" is the complaint that follows.
|
|
56
|
-
return (_jsxs(Row, { gap: 1, children: [_jsx("text", { content: theme.glyphs.chevronRight, fg: active ? 'accent' : 'subtle' }), _jsx("text", { content: block.text, fg: "subtle", italic: true, wrap: "word", flex: 1, ...hit }), _jsx("text", { content: active ? 'enter drops it' : 'queued', fg: "warning" })] }));
|
|
57
|
-
default:
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
});
|