@agentuity/coder 1.0.37
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 +57 -0
- package/dist/chain-preview.d.ts +55 -0
- package/dist/chain-preview.d.ts.map +1 -0
- package/dist/chain-preview.js +472 -0
- package/dist/chain-preview.js.map +1 -0
- package/dist/client.d.ts +43 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +402 -0
- package/dist/client.js.map +1 -0
- package/dist/commands.d.ts +22 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +99 -0
- package/dist/commands.js.map +1 -0
- package/dist/footer.d.ts +34 -0
- package/dist/footer.d.ts.map +1 -0
- package/dist/footer.js +249 -0
- package/dist/footer.js.map +1 -0
- package/dist/handlers.d.ts +24 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +83 -0
- package/dist/handlers.js.map +1 -0
- package/dist/hub-overlay.d.ts +107 -0
- package/dist/hub-overlay.d.ts.map +1 -0
- package/dist/hub-overlay.js +1794 -0
- package/dist/hub-overlay.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1585 -0
- package/dist/index.js.map +1 -0
- package/dist/output-viewer.d.ts +49 -0
- package/dist/output-viewer.d.ts.map +1 -0
- package/dist/output-viewer.js +389 -0
- package/dist/output-viewer.js.map +1 -0
- package/dist/overlay.d.ts +40 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +225 -0
- package/dist/overlay.js.map +1 -0
- package/dist/protocol.d.ts +118 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +3 -0
- package/dist/protocol.js.map +1 -0
- package/dist/remote-session.d.ts +113 -0
- package/dist/remote-session.d.ts.map +1 -0
- package/dist/remote-session.js +645 -0
- package/dist/remote-session.js.map +1 -0
- package/dist/remote-tui.d.ts +40 -0
- package/dist/remote-tui.d.ts.map +1 -0
- package/dist/remote-tui.js +606 -0
- package/dist/remote-tui.js.map +1 -0
- package/dist/renderers.d.ts +34 -0
- package/dist/renderers.d.ts.map +1 -0
- package/dist/renderers.js +669 -0
- package/dist/renderers.js.map +1 -0
- package/dist/review.d.ts +15 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +154 -0
- package/dist/review.js.map +1 -0
- package/dist/titlebar.d.ts +3 -0
- package/dist/titlebar.d.ts.map +1 -0
- package/dist/titlebar.js +59 -0
- package/dist/titlebar.js.map +1 -0
- package/dist/todo/index.d.ts +3 -0
- package/dist/todo/index.d.ts.map +1 -0
- package/dist/todo/index.js +3 -0
- package/dist/todo/index.js.map +1 -0
- package/dist/todo/store.d.ts +6 -0
- package/dist/todo/store.d.ts.map +1 -0
- package/dist/todo/store.js +43 -0
- package/dist/todo/store.js.map +1 -0
- package/dist/todo/types.d.ts +13 -0
- package/dist/todo/types.d.ts.map +1 -0
- package/dist/todo/types.js +2 -0
- package/dist/todo/types.js.map +1 -0
- package/package.json +44 -0
- package/src/chain-preview.ts +621 -0
- package/src/client.ts +515 -0
- package/src/commands.ts +132 -0
- package/src/footer.ts +305 -0
- package/src/handlers.ts +113 -0
- package/src/hub-overlay.ts +2324 -0
- package/src/index.ts +1907 -0
- package/src/output-viewer.ts +480 -0
- package/src/overlay.ts +294 -0
- package/src/protocol.ts +157 -0
- package/src/remote-session.ts +800 -0
- package/src/remote-tui.ts +707 -0
- package/src/renderers.ts +740 -0
- package/src/review.ts +201 -0
- package/src/titlebar.ts +63 -0
- package/src/todo/index.ts +2 -0
- package/src/todo/store.ts +49 -0
- package/src/todo/types.ts +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @agentuity/coder
|
|
2
|
+
|
|
3
|
+
Lightweight [Pi TUI](https://github.com/mariozechner/pi-coding-agent) extension that connects to the Agentuity Coder Hub.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package is a **pure protocol adapter** between Pi's extension API and the Coder Hub server. It contains zero hardcoded tool schemas or agent definitions — everything is driven by the server's `InitMessage` at startup.
|
|
8
|
+
|
|
9
|
+
The extension runs inside **Pi's Node.js process**, not the Agentuity runtime.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
| File | Lines | Role |
|
|
14
|
+
|------|-------|------|
|
|
15
|
+
| `src/index.ts` | ~660 | Main extension entry — tool/event registration, sub-agent execution |
|
|
16
|
+
| `src/handlers.ts` | ~100 | Action processing (ACK, BLOCK, RETURN, NOTIFY, CONFIRM, etc.) |
|
|
17
|
+
| `src/protocol.ts` | ~130 | TypeBox protocol types (InitMessage, requests, actions, responses) |
|
|
18
|
+
| `src/client.ts` | ~145 | HubClient — WebSocket client with request/response correlation |
|
|
19
|
+
|
|
20
|
+
## Connection Flow
|
|
21
|
+
|
|
22
|
+
1. **Extension loads** — `agentuityCoderHub(pi)` is called by Pi
|
|
23
|
+
2. **Sync bootstrap** — `fetchInitMessageSync()` calls Hub's REST `/api/hub/init` endpoint via `curl` + `execFileSync` to discover available tools and agents _before_ registration returns
|
|
24
|
+
3. **Tool registration** — Hub tools (memory, context7, etc.) are registered with Pi using server-provided JSON Schemas
|
|
25
|
+
4. **Lazy WebSocket** — On first event (`session_start`), a persistent WebSocket connection is established for runtime communication
|
|
26
|
+
5. **Event proxy** — Pi lifecycle events are forwarded to Hub; Hub responds with actions (ACK, BLOCK, SYSTEM_PROMPT, etc.)
|
|
27
|
+
6. **Tool execution** — When Pi invokes a Hub tool, the request is sent over WebSocket and the RETURN action result is passed back
|
|
28
|
+
|
|
29
|
+
## Sub-Agent Flow
|
|
30
|
+
|
|
31
|
+
1. **Lead delegates** — Lead agent calls the `task` or `parallel_tasks` tool
|
|
32
|
+
2. **In-process session** — `runSubAgent()` creates a Pi `createAgentSession()` inside the same process (no subprocess spawning)
|
|
33
|
+
3. **Hub tools via extensionFactories** — Sub-agents receive Hub tools (memory, context7, etc.) through Pi's `extensionFactories` mechanism, sharing the parent's WebSocket connection
|
|
34
|
+
4. **Isolation** — Sub-agents run with `noExtensions: true` to prevent recursive task tool registration
|
|
35
|
+
5. **Output limits** — Results are truncated to 200KB / 5K lines to prevent context bloat
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- **`curl` binary** — Required for the synchronous REST bootstrap (`fetchInitMessageSync`). Available by default on macOS, Linux, and Windows 10+.
|
|
40
|
+
- **Pi coding agent** — This extension is loaded by Pi's extension system.
|
|
41
|
+
|
|
42
|
+
## Environment Variables
|
|
43
|
+
|
|
44
|
+
| Variable | Required | Description |
|
|
45
|
+
|----------|----------|-------------|
|
|
46
|
+
| `AGENTUITY_CODER_HUB_URL` | Yes | WebSocket URL for the Coder Hub (e.g., `ws://localhost:3000/api/ws`) |
|
|
47
|
+
| `AGENTUITY_CODER_AGENT` | No | Agent role name. If set, the extension runs as a sub-agent (not lead). |
|
|
48
|
+
|
|
49
|
+
## Design Decisions
|
|
50
|
+
|
|
51
|
+
### Why `curl` + `execFileSync`?
|
|
52
|
+
|
|
53
|
+
Pi's extension registration is **synchronous** — tools must be registered before the extension function returns. Node's `fetch()` is async-only, and `Bun.spawnSync` isn't available in Pi's Node.js runtime. Using `curl` via `execFileSync` is the simplest way to make a synchronous HTTP request without adding dependencies.
|
|
54
|
+
|
|
55
|
+
### Why no hardcoded schemas?
|
|
56
|
+
|
|
57
|
+
The Hub server is the single source of truth for tool definitions, agent configurations, and system prompts. This keeps the extension thin and allows the Hub to evolve without extension updates.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Theme } from '@mariozechner/pi-coding-agent';
|
|
2
|
+
import type { AgentDefinition } from './protocol.ts';
|
|
3
|
+
export interface ChainResult {
|
|
4
|
+
mode: 'sequential' | 'parallel';
|
|
5
|
+
steps: Array<{
|
|
6
|
+
agent: string;
|
|
7
|
+
task: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
interface Component {
|
|
11
|
+
render(width: number): string[];
|
|
12
|
+
handleInput?(data: string): void;
|
|
13
|
+
invalidate(): void;
|
|
14
|
+
}
|
|
15
|
+
interface Focusable {
|
|
16
|
+
focused: boolean;
|
|
17
|
+
}
|
|
18
|
+
type DoneFn = (result: ChainResult | undefined) => void;
|
|
19
|
+
export declare class ChainEditorOverlay implements Component, Focusable {
|
|
20
|
+
focused: boolean;
|
|
21
|
+
private readonly theme;
|
|
22
|
+
private readonly done;
|
|
23
|
+
private readonly agentByName;
|
|
24
|
+
private readonly availableAgents;
|
|
25
|
+
private mode;
|
|
26
|
+
private screen;
|
|
27
|
+
private steps;
|
|
28
|
+
private selectedStepIndex;
|
|
29
|
+
private statusMessage;
|
|
30
|
+
private readonly maxVisibleItems;
|
|
31
|
+
private pickerIndex;
|
|
32
|
+
private pickerFilter;
|
|
33
|
+
private editBuffer;
|
|
34
|
+
private editCursor;
|
|
35
|
+
private previousTask;
|
|
36
|
+
private disposed;
|
|
37
|
+
constructor(theme: Theme, agents: AgentDefinition[], done: DoneFn, initialAgents?: string[]);
|
|
38
|
+
handleInput(data: string): void;
|
|
39
|
+
render(width: number): string[];
|
|
40
|
+
invalidate(): void;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
private buildInitialSteps;
|
|
43
|
+
private handleComposeInput;
|
|
44
|
+
private handlePickerInput;
|
|
45
|
+
private handleEditInput;
|
|
46
|
+
private getFilteredAgents;
|
|
47
|
+
private renderComposeScreen;
|
|
48
|
+
private renderPickerScreen;
|
|
49
|
+
private contentLine;
|
|
50
|
+
private getStepVisibleRange;
|
|
51
|
+
private getPickerVisibleRange;
|
|
52
|
+
private close;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=chain-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-preview.d.ts","sourceRoot":"","sources":["../src/chain-preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;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EACzB,IAAI,EAAE,MAAM,EACZ,aAAa,GAAE,MAAM,EAAO;IAS7B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgB/B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAa/B,UAAU,IAAI,IAAI;IAIlB,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,kBAAkB;IAkF1B,OAAO,CAAC,iBAAiB;IAyDzB,OAAO,CAAC,eAAe;IAgFvB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,mBAAmB;IA2G3B,OAAO,CAAC,kBAAkB;IA8E1B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,KAAK;CAKb"}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { matchesKey } from '@mariozechner/pi-tui';
|
|
2
|
+
import { truncateToWidth } from "./renderers.js";
|
|
3
|
+
const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
4
|
+
function visibleWidth(text) {
|
|
5
|
+
return text.replace(ANSI_RE, '').length;
|
|
6
|
+
}
|
|
7
|
+
function padRight(text, width) {
|
|
8
|
+
if (width <= 0)
|
|
9
|
+
return '';
|
|
10
|
+
const truncated = truncateToWidth(text, width);
|
|
11
|
+
const remaining = width - visibleWidth(truncated);
|
|
12
|
+
return remaining > 0 ? truncated + ' '.repeat(remaining) : truncated;
|
|
13
|
+
}
|
|
14
|
+
function hLine(width) {
|
|
15
|
+
return width > 0 ? '─'.repeat(width) : '';
|
|
16
|
+
}
|
|
17
|
+
function buildTopBorder(width, title) {
|
|
18
|
+
if (width <= 0)
|
|
19
|
+
return '';
|
|
20
|
+
if (width === 1)
|
|
21
|
+
return '╭';
|
|
22
|
+
if (width === 2)
|
|
23
|
+
return '╭╮';
|
|
24
|
+
const inner = width - 2;
|
|
25
|
+
const titleText = ` ${title} `;
|
|
26
|
+
if (titleText.length >= inner) {
|
|
27
|
+
return `╭${hLine(inner)}╮`;
|
|
28
|
+
}
|
|
29
|
+
const left = Math.floor((inner - titleText.length) / 2);
|
|
30
|
+
const right = inner - titleText.length - left;
|
|
31
|
+
return `╭${hLine(left)}${titleText}${hLine(right)}╮`;
|
|
32
|
+
}
|
|
33
|
+
function buildBottomBorder(width) {
|
|
34
|
+
if (width <= 0)
|
|
35
|
+
return '';
|
|
36
|
+
if (width === 1)
|
|
37
|
+
return '╰';
|
|
38
|
+
if (width === 2)
|
|
39
|
+
return '╰╯';
|
|
40
|
+
return `╰${hLine(width - 2)}╯`;
|
|
41
|
+
}
|
|
42
|
+
function parsePrintableChar(data) {
|
|
43
|
+
if (!data || data.length !== 1)
|
|
44
|
+
return null;
|
|
45
|
+
const code = data.charCodeAt(0);
|
|
46
|
+
if (code < 32 || code === 127)
|
|
47
|
+
return null;
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
export class ChainEditorOverlay {
|
|
51
|
+
focused = true;
|
|
52
|
+
theme;
|
|
53
|
+
done;
|
|
54
|
+
agentByName;
|
|
55
|
+
availableAgents;
|
|
56
|
+
mode = 'sequential';
|
|
57
|
+
screen = 'compose';
|
|
58
|
+
steps;
|
|
59
|
+
selectedStepIndex = 0;
|
|
60
|
+
statusMessage = '';
|
|
61
|
+
maxVisibleItems = 6;
|
|
62
|
+
pickerIndex = 0;
|
|
63
|
+
pickerFilter = '';
|
|
64
|
+
editBuffer = '';
|
|
65
|
+
editCursor = 0;
|
|
66
|
+
previousTask = '';
|
|
67
|
+
disposed = false;
|
|
68
|
+
constructor(theme, agents, done, initialAgents = []) {
|
|
69
|
+
this.theme = theme;
|
|
70
|
+
this.done = done;
|
|
71
|
+
this.availableAgents = [...agents];
|
|
72
|
+
this.agentByName = new Map(agents.map((agent) => [agent.name, agent]));
|
|
73
|
+
this.steps = this.buildInitialSteps(initialAgents);
|
|
74
|
+
}
|
|
75
|
+
handleInput(data) {
|
|
76
|
+
if (this.disposed)
|
|
77
|
+
return;
|
|
78
|
+
if (this.screen === 'picker') {
|
|
79
|
+
this.handlePickerInput(data);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this.screen === 'edit') {
|
|
83
|
+
this.handleEditInput(data);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.handleComposeInput(data);
|
|
87
|
+
}
|
|
88
|
+
render(width) {
|
|
89
|
+
const safeWidth = Math.max(4, width);
|
|
90
|
+
const termHeight = process.stdout.rows || 40;
|
|
91
|
+
// Match overlay maxHeight of 95%, leave margin for overlay chrome
|
|
92
|
+
const maxLines = Math.max(10, Math.floor(termHeight * 0.95) - 2);
|
|
93
|
+
const lines = this.screen === 'picker'
|
|
94
|
+
? this.renderPickerScreen(safeWidth, maxLines)
|
|
95
|
+
: this.renderComposeScreen(safeWidth, maxLines);
|
|
96
|
+
return lines.map((line) => truncateToWidth(line, safeWidth));
|
|
97
|
+
}
|
|
98
|
+
invalidate() {
|
|
99
|
+
// Stateless rendering; no cache invalidation required.
|
|
100
|
+
}
|
|
101
|
+
dispose() {
|
|
102
|
+
this.disposed = true;
|
|
103
|
+
}
|
|
104
|
+
buildInitialSteps(initialAgents) {
|
|
105
|
+
const names = initialAgents
|
|
106
|
+
.map((name) => name.trim())
|
|
107
|
+
.filter((name) => name.length > 0)
|
|
108
|
+
.filter((name) => this.agentByName.has(name));
|
|
109
|
+
return names.map((agent, index) => ({
|
|
110
|
+
agent,
|
|
111
|
+
task: index === 0 ? '' : '(from previous step)',
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
handleComposeInput(data) {
|
|
115
|
+
if (matchesKey(data, 'escape')) {
|
|
116
|
+
this.close(undefined);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (matchesKey(data, 'up')) {
|
|
120
|
+
if (this.steps.length > 0) {
|
|
121
|
+
this.selectedStepIndex =
|
|
122
|
+
(this.selectedStepIndex - 1 + this.steps.length) % this.steps.length;
|
|
123
|
+
this.statusMessage = '';
|
|
124
|
+
}
|
|
125
|
+
this.invalidate();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (matchesKey(data, 'down')) {
|
|
129
|
+
if (this.steps.length > 0) {
|
|
130
|
+
this.selectedStepIndex = (this.selectedStepIndex + 1) % this.steps.length;
|
|
131
|
+
this.statusMessage = '';
|
|
132
|
+
}
|
|
133
|
+
this.invalidate();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (matchesKey(data, 'a') || data.toLowerCase() === 'a') {
|
|
137
|
+
this.screen = 'picker';
|
|
138
|
+
this.pickerFilter = '';
|
|
139
|
+
this.pickerIndex = 0;
|
|
140
|
+
this.statusMessage = '';
|
|
141
|
+
this.invalidate();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (matchesKey(data, 'd') || matchesKey(data, 'delete') || data.toLowerCase() === 'd') {
|
|
145
|
+
if (this.steps.length > 0) {
|
|
146
|
+
this.steps.splice(this.selectedStepIndex, 1);
|
|
147
|
+
if (this.selectedStepIndex >= this.steps.length) {
|
|
148
|
+
this.selectedStepIndex = Math.max(0, this.steps.length - 1);
|
|
149
|
+
}
|
|
150
|
+
this.statusMessage = '';
|
|
151
|
+
this.invalidate();
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (matchesKey(data, 'e') || data.toLowerCase() === 'e') {
|
|
156
|
+
const selected = this.steps[this.selectedStepIndex];
|
|
157
|
+
if (!selected)
|
|
158
|
+
return;
|
|
159
|
+
this.previousTask = selected.task;
|
|
160
|
+
this.editBuffer = selected.task;
|
|
161
|
+
this.editCursor = this.editBuffer.length;
|
|
162
|
+
this.screen = 'edit';
|
|
163
|
+
this.statusMessage = '';
|
|
164
|
+
this.invalidate();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (matchesKey(data, 'p') || data.toLowerCase() === 'p') {
|
|
168
|
+
this.mode = this.mode === 'sequential' ? 'parallel' : 'sequential';
|
|
169
|
+
this.statusMessage = '';
|
|
170
|
+
this.invalidate();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (matchesKey(data, 'enter')) {
|
|
174
|
+
if (this.steps.length < 2) {
|
|
175
|
+
this.statusMessage = 'Need at least 2 steps to run.';
|
|
176
|
+
this.invalidate();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.close({
|
|
180
|
+
mode: this.mode,
|
|
181
|
+
steps: this.steps.map((step) => ({
|
|
182
|
+
agent: step.agent,
|
|
183
|
+
task: step.task,
|
|
184
|
+
})),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
handlePickerInput(data) {
|
|
189
|
+
if (matchesKey(data, 'escape')) {
|
|
190
|
+
this.screen = 'compose';
|
|
191
|
+
this.invalidate();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const filtered = this.getFilteredAgents();
|
|
195
|
+
if (matchesKey(data, 'up')) {
|
|
196
|
+
if (filtered.length > 0) {
|
|
197
|
+
this.pickerIndex = (this.pickerIndex - 1 + filtered.length) % filtered.length;
|
|
198
|
+
}
|
|
199
|
+
this.invalidate();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (matchesKey(data, 'down')) {
|
|
203
|
+
if (filtered.length > 0) {
|
|
204
|
+
this.pickerIndex = (this.pickerIndex + 1) % filtered.length;
|
|
205
|
+
}
|
|
206
|
+
this.invalidate();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (matchesKey(data, 'backspace')) {
|
|
210
|
+
if (this.pickerFilter.length > 0) {
|
|
211
|
+
this.pickerFilter = this.pickerFilter.slice(0, -1);
|
|
212
|
+
this.pickerIndex = 0;
|
|
213
|
+
this.invalidate();
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (matchesKey(data, 'enter')) {
|
|
218
|
+
const selected = filtered[this.pickerIndex];
|
|
219
|
+
if (!selected)
|
|
220
|
+
return;
|
|
221
|
+
this.steps.push({
|
|
222
|
+
agent: selected.name,
|
|
223
|
+
task: this.steps.length === 0 ? '' : '(from previous step)',
|
|
224
|
+
});
|
|
225
|
+
this.selectedStepIndex = this.steps.length - 1;
|
|
226
|
+
this.screen = 'compose';
|
|
227
|
+
this.statusMessage = '';
|
|
228
|
+
this.invalidate();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const char = parsePrintableChar(data);
|
|
232
|
+
if (char) {
|
|
233
|
+
this.pickerFilter += char;
|
|
234
|
+
this.pickerIndex = 0;
|
|
235
|
+
this.invalidate();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
handleEditInput(data) {
|
|
239
|
+
const selected = this.steps[this.selectedStepIndex];
|
|
240
|
+
if (!selected) {
|
|
241
|
+
this.screen = 'compose';
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (matchesKey(data, 'escape')) {
|
|
245
|
+
selected.task = this.previousTask;
|
|
246
|
+
this.screen = 'compose';
|
|
247
|
+
this.invalidate();
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (matchesKey(data, 'enter')) {
|
|
251
|
+
selected.task = this.editBuffer;
|
|
252
|
+
this.screen = 'compose';
|
|
253
|
+
this.invalidate();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (matchesKey(data, 'left')) {
|
|
257
|
+
this.editCursor = Math.max(0, this.editCursor - 1);
|
|
258
|
+
this.invalidate();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (matchesKey(data, 'right')) {
|
|
262
|
+
this.editCursor = Math.min(this.editBuffer.length, this.editCursor + 1);
|
|
263
|
+
this.invalidate();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (matchesKey(data, 'home')) {
|
|
267
|
+
this.editCursor = 0;
|
|
268
|
+
this.invalidate();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (matchesKey(data, 'end')) {
|
|
272
|
+
this.editCursor = this.editBuffer.length;
|
|
273
|
+
this.invalidate();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (matchesKey(data, 'backspace')) {
|
|
277
|
+
if (this.editCursor > 0) {
|
|
278
|
+
this.editBuffer =
|
|
279
|
+
this.editBuffer.slice(0, this.editCursor - 1) +
|
|
280
|
+
this.editBuffer.slice(this.editCursor);
|
|
281
|
+
this.editCursor -= 1;
|
|
282
|
+
selected.task = this.editBuffer;
|
|
283
|
+
this.invalidate();
|
|
284
|
+
}
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (matchesKey(data, 'delete')) {
|
|
288
|
+
if (this.editCursor < this.editBuffer.length) {
|
|
289
|
+
this.editBuffer =
|
|
290
|
+
this.editBuffer.slice(0, this.editCursor) +
|
|
291
|
+
this.editBuffer.slice(this.editCursor + 1);
|
|
292
|
+
selected.task = this.editBuffer;
|
|
293
|
+
this.invalidate();
|
|
294
|
+
}
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const char = parsePrintableChar(data);
|
|
298
|
+
if (char) {
|
|
299
|
+
this.editBuffer =
|
|
300
|
+
this.editBuffer.slice(0, this.editCursor) +
|
|
301
|
+
char +
|
|
302
|
+
this.editBuffer.slice(this.editCursor);
|
|
303
|
+
this.editCursor += char.length;
|
|
304
|
+
selected.task = this.editBuffer;
|
|
305
|
+
this.invalidate();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
getFilteredAgents() {
|
|
309
|
+
const query = this.pickerFilter.trim().toLowerCase();
|
|
310
|
+
if (!query)
|
|
311
|
+
return this.availableAgents;
|
|
312
|
+
return this.availableAgents.filter((agent) => {
|
|
313
|
+
const haystack = `${agent.name} ${agent.description}`.toLowerCase();
|
|
314
|
+
return haystack.includes(query);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
renderComposeScreen(width, maxLines) {
|
|
318
|
+
const inner = Math.max(0, width - 2);
|
|
319
|
+
// Fixed header (always rendered)
|
|
320
|
+
const chainSummary = this.steps.length > 0 ? this.steps.map((step) => step.agent).join(' → ') : '(empty)';
|
|
321
|
+
const header = [
|
|
322
|
+
buildTopBorder(width, 'Chain Editor'),
|
|
323
|
+
this.contentLine('', inner),
|
|
324
|
+
this.contentLine(this.theme.fg('text', ` Chain: ${chainSummary}`), inner),
|
|
325
|
+
this.contentLine(this.theme.fg('muted', ` Mode: ${this.mode}`), inner),
|
|
326
|
+
this.contentLine('', inner),
|
|
327
|
+
];
|
|
328
|
+
// Fixed footer (always rendered)
|
|
329
|
+
const hintRun = this.steps.length >= 2 ? '[Enter] Run' : '[Enter] Run (needs 2+ steps)';
|
|
330
|
+
const footer = [
|
|
331
|
+
this.contentLine(this.theme.fg('dim', ` [↑↓] Navigate [e] Edit task [d] Remove`), inner),
|
|
332
|
+
this.contentLine(this.theme.fg('dim', ` [a] Add step [p] Toggle mode ${hintRun} [Esc] Cancel`), inner),
|
|
333
|
+
buildBottomBorder(width),
|
|
334
|
+
];
|
|
335
|
+
// Available lines for scrollable content area
|
|
336
|
+
const contentBudget = Math.max(4, maxLines - header.length - footer.length);
|
|
337
|
+
if (this.steps.length === 0) {
|
|
338
|
+
const content = [
|
|
339
|
+
this.contentLine(this.theme.fg('muted', ' No steps yet. Press [a] to add an agent step.'), inner),
|
|
340
|
+
this.contentLine('', inner),
|
|
341
|
+
];
|
|
342
|
+
return [...header, ...content, ...footer];
|
|
343
|
+
}
|
|
344
|
+
// Each step takes 3 lines (name+model, task, empty) or 4 lines (with edit hint)
|
|
345
|
+
const LINES_PER_STEP = 3;
|
|
346
|
+
// Reserve 2 lines for possible scroll indicators + status message
|
|
347
|
+
const scrollReserve = this.statusMessage ? 3 : 2;
|
|
348
|
+
const maxSteps = Math.max(1, Math.floor((contentBudget - scrollReserve) / LINES_PER_STEP));
|
|
349
|
+
const windowSize = Math.min(maxSteps, this.steps.length);
|
|
350
|
+
const [startIdx, endIdx] = this.getStepVisibleRange(windowSize);
|
|
351
|
+
const content = [];
|
|
352
|
+
if (startIdx > 0) {
|
|
353
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↑ ${startIdx} more above`), inner));
|
|
354
|
+
}
|
|
355
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
356
|
+
const step = this.steps[i];
|
|
357
|
+
const selected = i === this.selectedStepIndex;
|
|
358
|
+
const marker = selected ? this.theme.fg('accent', '►') : ' ';
|
|
359
|
+
const agent = this.agentByName.get(step.agent);
|
|
360
|
+
const model = agent?.model ? this.theme.fg('dim', ` [${agent.model}]`) : '';
|
|
361
|
+
content.push(this.contentLine(`${marker} ${this.theme.bold(`Step ${i + 1}: ${step.agent}`)}${model}`, inner));
|
|
362
|
+
if (this.screen === 'edit' && selected) {
|
|
363
|
+
const displayTask = this.editBuffer.slice(0, this.editCursor) +
|
|
364
|
+
this.theme.fg('accent', '│') +
|
|
365
|
+
this.editBuffer.slice(this.editCursor);
|
|
366
|
+
content.push(this.contentLine(this.theme.fg('text', ` task: ${displayTask}`), inner));
|
|
367
|
+
content.push(this.contentLine(this.theme.fg('dim', ' editing: [Enter] Save [Esc] Cancel [←→] Move cursor'), inner));
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
const task = step.task || this.theme.fg('muted', '(empty)');
|
|
371
|
+
content.push(this.contentLine(this.theme.fg('text', ` task: ${task}`), inner));
|
|
372
|
+
}
|
|
373
|
+
content.push(this.contentLine('', inner));
|
|
374
|
+
}
|
|
375
|
+
if (endIdx < this.steps.length) {
|
|
376
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↓ ${this.steps.length - endIdx} more below`), inner));
|
|
377
|
+
}
|
|
378
|
+
if (this.statusMessage) {
|
|
379
|
+
content.push(this.contentLine(this.theme.fg('warning', ` ${this.statusMessage}`), inner));
|
|
380
|
+
}
|
|
381
|
+
return [...header, ...content, ...footer];
|
|
382
|
+
}
|
|
383
|
+
renderPickerScreen(width, maxLines) {
|
|
384
|
+
const inner = Math.max(0, width - 2);
|
|
385
|
+
const filtered = this.getFilteredAgents();
|
|
386
|
+
if (this.pickerIndex >= filtered.length) {
|
|
387
|
+
this.pickerIndex = Math.max(0, filtered.length - 1);
|
|
388
|
+
}
|
|
389
|
+
// Fixed header (always rendered)
|
|
390
|
+
const header = [
|
|
391
|
+
buildTopBorder(width, 'Add Agent Step'),
|
|
392
|
+
this.contentLine('', inner),
|
|
393
|
+
this.contentLine(this.theme.fg('text', ` Filter: ${this.pickerFilter || '(type to filter)'}`), inner),
|
|
394
|
+
this.contentLine('', inner),
|
|
395
|
+
];
|
|
396
|
+
// Fixed footer (always rendered)
|
|
397
|
+
const footer = [
|
|
398
|
+
this.contentLine(this.theme.fg('dim', ' [↑↓] Navigate [Enter] Select [Esc] Back [Backspace] Filter'), inner),
|
|
399
|
+
buildBottomBorder(width),
|
|
400
|
+
];
|
|
401
|
+
// Available lines for scrollable content area
|
|
402
|
+
const contentBudget = Math.max(4, maxLines - header.length - footer.length);
|
|
403
|
+
if (filtered.length === 0) {
|
|
404
|
+
const content = [
|
|
405
|
+
this.contentLine(this.theme.fg('muted', ' No agents match filter.'), inner),
|
|
406
|
+
this.contentLine('', inner),
|
|
407
|
+
];
|
|
408
|
+
return [...header, ...content, ...footer];
|
|
409
|
+
}
|
|
410
|
+
// Each agent takes 3 lines: name, description, empty line
|
|
411
|
+
const LINES_PER_AGENT = 3;
|
|
412
|
+
// Reserve 2 lines for possible scroll indicators
|
|
413
|
+
const scrollReserve = 2;
|
|
414
|
+
const maxAgents = Math.max(1, Math.floor((contentBudget - scrollReserve) / LINES_PER_AGENT));
|
|
415
|
+
const windowSize = Math.min(maxAgents, filtered.length);
|
|
416
|
+
const [startIdx, endIdx] = this.getPickerVisibleRange(filtered.length, windowSize);
|
|
417
|
+
const content = [];
|
|
418
|
+
if (startIdx > 0) {
|
|
419
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↑ ${startIdx} more above`), inner));
|
|
420
|
+
}
|
|
421
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
422
|
+
const agent = filtered[i];
|
|
423
|
+
const selected = i === this.pickerIndex;
|
|
424
|
+
const marker = selected ? this.theme.fg('accent', '► ') : ' ';
|
|
425
|
+
const model = agent.model ? this.theme.fg('dim', ` [${agent.model}]`) : '';
|
|
426
|
+
content.push(this.contentLine(`${marker}${this.theme.bold(agent.name)}${model}`, inner));
|
|
427
|
+
content.push(this.contentLine(this.theme.fg('muted', ` ${agent.description || ''}`), inner));
|
|
428
|
+
content.push(this.contentLine('', inner));
|
|
429
|
+
}
|
|
430
|
+
if (endIdx < filtered.length) {
|
|
431
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↓ ${filtered.length - endIdx} more below`), inner));
|
|
432
|
+
}
|
|
433
|
+
return [...header, ...content, ...footer];
|
|
434
|
+
}
|
|
435
|
+
contentLine(content, innerWidth) {
|
|
436
|
+
return `│${padRight(content, innerWidth)}│`;
|
|
437
|
+
}
|
|
438
|
+
getStepVisibleRange(windowSize) {
|
|
439
|
+
const count = this.steps.length;
|
|
440
|
+
const ws = windowSize ?? this.maxVisibleItems;
|
|
441
|
+
if (count <= ws)
|
|
442
|
+
return [0, count];
|
|
443
|
+
const half = Math.floor(ws / 2);
|
|
444
|
+
let start = Math.max(0, this.selectedStepIndex - half);
|
|
445
|
+
let end = start + ws;
|
|
446
|
+
if (end > count) {
|
|
447
|
+
end = count;
|
|
448
|
+
start = Math.max(0, end - ws);
|
|
449
|
+
}
|
|
450
|
+
return [start, end];
|
|
451
|
+
}
|
|
452
|
+
getPickerVisibleRange(count, windowSize) {
|
|
453
|
+
const ws = windowSize ?? this.maxVisibleItems;
|
|
454
|
+
if (count <= ws)
|
|
455
|
+
return [0, count];
|
|
456
|
+
const half = Math.floor(ws / 2);
|
|
457
|
+
let start = Math.max(0, this.pickerIndex - half);
|
|
458
|
+
let end = start + ws;
|
|
459
|
+
if (end > count) {
|
|
460
|
+
end = count;
|
|
461
|
+
start = Math.max(0, end - ws);
|
|
462
|
+
}
|
|
463
|
+
return [start, end];
|
|
464
|
+
}
|
|
465
|
+
close(result) {
|
|
466
|
+
if (this.disposed)
|
|
467
|
+
return;
|
|
468
|
+
this.disposed = true;
|
|
469
|
+
this.done(result);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
//# sourceMappingURL=chain-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-preview.js","sourceRoot":"","sources":["../src/chain-preview.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA6BjD,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC,SAAS,YAAY,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;AACzC,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAa;IAC5C,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC3B,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IACnD,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1B,IAAI,KAAK,KAAK,CAAC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EAAE,GAAG,CAAC,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,MAA+B;QAC5C,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC;CACD"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { InitMessage, HubRequest, HubResponse } from './protocol.ts';
|
|
2
|
+
export type ConnectionState = 'connected' | 'disconnected' | 'reconnecting' | 'closed';
|
|
3
|
+
export declare class HubClient {
|
|
4
|
+
private ws;
|
|
5
|
+
private reconnectAttempts;
|
|
6
|
+
private reconnectTimer;
|
|
7
|
+
private intentionallyClosed;
|
|
8
|
+
private lastConnectUrl;
|
|
9
|
+
private queue;
|
|
10
|
+
private connectionStateListeners;
|
|
11
|
+
private pending;
|
|
12
|
+
connectionState: ConnectionState;
|
|
13
|
+
onConnectionStateChange?: (state: ConnectionState) => void;
|
|
14
|
+
onBeforeReconnect?: () => Promise<void>;
|
|
15
|
+
onInitMessage?: (initMessage: InitMessage) => void;
|
|
16
|
+
/** Called when an unsolicited server message arrives (broadcast, presence, hydration). */
|
|
17
|
+
onServerMessage?: (message: Record<string, unknown>) => void;
|
|
18
|
+
/** API key for Hub authentication (sent as x-agentuity-auth-api-key header) */
|
|
19
|
+
apiKey: string | null;
|
|
20
|
+
private setConnectionState;
|
|
21
|
+
private buildWebSocketUrl;
|
|
22
|
+
private enqueue;
|
|
23
|
+
private sendRequestNow;
|
|
24
|
+
private sendFireAndForgetNow;
|
|
25
|
+
private flushQueue;
|
|
26
|
+
private handleUnexpectedClose;
|
|
27
|
+
private clearReconnectTimer;
|
|
28
|
+
private rejectQueuedRequests;
|
|
29
|
+
private startReconnectLoop;
|
|
30
|
+
private connectInternal;
|
|
31
|
+
connect(url: string, opts?: {
|
|
32
|
+
sessionId?: string;
|
|
33
|
+
role?: string;
|
|
34
|
+
}): Promise<InitMessage>;
|
|
35
|
+
private waitForConnection;
|
|
36
|
+
nextId(): string;
|
|
37
|
+
send(request: HubRequest): Promise<HubResponse>;
|
|
38
|
+
sendNoWait(message: HubRequest | Record<string, unknown>): void;
|
|
39
|
+
waitUntilConnected(timeoutMs?: number): Promise<void>;
|
|
40
|
+
close(): void;
|
|
41
|
+
get connected(): boolean;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|