@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/dist/overlay.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
export class AgentManagerOverlay {
|
|
43
|
+
focused = true;
|
|
44
|
+
theme;
|
|
45
|
+
agents;
|
|
46
|
+
done;
|
|
47
|
+
screen = 'list';
|
|
48
|
+
selectedIndex = 0;
|
|
49
|
+
listWindowSize = 6;
|
|
50
|
+
disposed = false;
|
|
51
|
+
constructor(theme, agents, done) {
|
|
52
|
+
this.theme = theme;
|
|
53
|
+
this.agents = agents;
|
|
54
|
+
this.done = done;
|
|
55
|
+
}
|
|
56
|
+
handleInput(data) {
|
|
57
|
+
if (this.disposed)
|
|
58
|
+
return;
|
|
59
|
+
if (matchesKey(data, 'escape')) {
|
|
60
|
+
if (this.screen === 'detail') {
|
|
61
|
+
this.screen = 'list';
|
|
62
|
+
this.invalidate();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.close(undefined);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (this.screen === 'list') {
|
|
69
|
+
this.handleListInput(data);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.handleDetailInput(data);
|
|
73
|
+
}
|
|
74
|
+
render(width) {
|
|
75
|
+
const safeWidth = Math.max(4, width);
|
|
76
|
+
const termHeight = process.stdout.rows || 40;
|
|
77
|
+
// Match overlay maxHeight of 95%, leave margin for overlay chrome
|
|
78
|
+
const maxLines = Math.max(10, Math.floor(termHeight * 0.95) - 2);
|
|
79
|
+
const lines = this.screen === 'detail'
|
|
80
|
+
? this.renderDetailScreen(safeWidth)
|
|
81
|
+
: this.renderListScreen(safeWidth, maxLines);
|
|
82
|
+
return lines.map((line) => truncateToWidth(line, safeWidth));
|
|
83
|
+
}
|
|
84
|
+
invalidate() {
|
|
85
|
+
// Stateless rendering; no cache invalidation required.
|
|
86
|
+
}
|
|
87
|
+
dispose() {
|
|
88
|
+
this.disposed = true;
|
|
89
|
+
}
|
|
90
|
+
handleListInput(data) {
|
|
91
|
+
const count = this.agents.length;
|
|
92
|
+
if (count === 0)
|
|
93
|
+
return;
|
|
94
|
+
if (matchesKey(data, 'up')) {
|
|
95
|
+
this.selectedIndex = (this.selectedIndex - 1 + count) % count;
|
|
96
|
+
this.invalidate();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (matchesKey(data, 'down')) {
|
|
100
|
+
this.selectedIndex = (this.selectedIndex + 1) % count;
|
|
101
|
+
this.invalidate();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (matchesKey(data, 'enter')) {
|
|
105
|
+
this.screen = 'detail';
|
|
106
|
+
this.invalidate();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
handleDetailInput(data) {
|
|
110
|
+
if (matchesKey(data, 'r') || data.toLowerCase() === 'r') {
|
|
111
|
+
const selected = this.agents[this.selectedIndex];
|
|
112
|
+
if (!selected)
|
|
113
|
+
return;
|
|
114
|
+
this.close({ action: 'run', agent: selected.name });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
close(result) {
|
|
118
|
+
if (this.disposed)
|
|
119
|
+
return;
|
|
120
|
+
this.disposed = true;
|
|
121
|
+
this.done(result);
|
|
122
|
+
}
|
|
123
|
+
renderListScreen(width, maxLines) {
|
|
124
|
+
const inner = Math.max(0, width - 2);
|
|
125
|
+
// Fixed header (always rendered)
|
|
126
|
+
const header = [
|
|
127
|
+
buildTopBorder(width, 'Agent Manager'),
|
|
128
|
+
this.contentLine('', inner),
|
|
129
|
+
];
|
|
130
|
+
// Fixed footer (always rendered)
|
|
131
|
+
const footer = [
|
|
132
|
+
this.contentLine(this.theme.fg('dim', ' [↑↓] Navigate [Enter] Details [Esc] Close'), inner),
|
|
133
|
+
buildBottomBorder(width),
|
|
134
|
+
];
|
|
135
|
+
// Available lines for scrollable content area
|
|
136
|
+
const contentBudget = Math.max(4, maxLines - header.length - footer.length);
|
|
137
|
+
if (this.agents.length === 0) {
|
|
138
|
+
const content = [
|
|
139
|
+
this.contentLine(this.theme.fg('muted', ' No agents available'), inner),
|
|
140
|
+
this.contentLine('', inner),
|
|
141
|
+
];
|
|
142
|
+
return [...header, ...content, ...footer];
|
|
143
|
+
}
|
|
144
|
+
// Each agent takes 4 lines: name, description, capabilities, empty line
|
|
145
|
+
const LINES_PER_AGENT = 4;
|
|
146
|
+
// Reserve 2 lines for possible scroll indicators
|
|
147
|
+
const scrollReserve = 2;
|
|
148
|
+
const maxAgents = Math.max(1, Math.floor((contentBudget - scrollReserve) / LINES_PER_AGENT));
|
|
149
|
+
// Dynamic window size based on available space
|
|
150
|
+
const windowSize = Math.min(maxAgents, this.agents.length);
|
|
151
|
+
const [start, end] = this.getVisibleRange(windowSize);
|
|
152
|
+
const content = [];
|
|
153
|
+
if (start > 0) {
|
|
154
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↑ ${start} more above`), inner));
|
|
155
|
+
}
|
|
156
|
+
for (let i = start; i < end; i++) {
|
|
157
|
+
const agent = this.agents[i];
|
|
158
|
+
const selected = i === this.selectedIndex;
|
|
159
|
+
const prefix = selected ? this.theme.fg('accent', '› ') : ' ';
|
|
160
|
+
const model = agent.model ? this.theme.fg('dim', ` [${agent.model}]`) : '';
|
|
161
|
+
const readOnly = agent.readOnly ? this.theme.fg('warning', ' read-only') : '';
|
|
162
|
+
const title = `${prefix}${this.theme.bold(agent.name)}${model}${readOnly}`;
|
|
163
|
+
content.push(this.contentLine(title, inner));
|
|
164
|
+
const description = this.theme.fg('text', ` ${agent.description || 'No description'}`);
|
|
165
|
+
content.push(this.contentLine(description, inner));
|
|
166
|
+
const capsText = agent.capabilities?.length ? agent.capabilities.join(', ') : 'none';
|
|
167
|
+
const caps = this.theme.fg('muted', ` capabilities: ${capsText}`);
|
|
168
|
+
content.push(this.contentLine(caps, inner));
|
|
169
|
+
content.push(this.contentLine('', inner));
|
|
170
|
+
}
|
|
171
|
+
if (end < this.agents.length) {
|
|
172
|
+
content.push(this.contentLine(this.theme.fg('dim', ` ↓ ${this.agents.length - end} more below`), inner));
|
|
173
|
+
}
|
|
174
|
+
return [...header, ...content, ...footer];
|
|
175
|
+
}
|
|
176
|
+
renderDetailScreen(width) {
|
|
177
|
+
const inner = Math.max(0, width - 2);
|
|
178
|
+
const lines = [];
|
|
179
|
+
const agent = this.agents[this.selectedIndex];
|
|
180
|
+
lines.push(buildTopBorder(width, agent?.name || 'Agent'));
|
|
181
|
+
lines.push(this.contentLine('', inner));
|
|
182
|
+
if (!agent) {
|
|
183
|
+
lines.push(this.contentLine(this.theme.fg('error', ' Agent not found'), inner));
|
|
184
|
+
lines.push(this.contentLine('', inner));
|
|
185
|
+
lines.push(this.contentLine(this.theme.fg('dim', ' [Esc] Back'), inner));
|
|
186
|
+
lines.push(buildBottomBorder(width));
|
|
187
|
+
return lines;
|
|
188
|
+
}
|
|
189
|
+
const readOnly = agent.readOnly ? 'yes' : 'no';
|
|
190
|
+
const capabilities = agent.capabilities?.length ? agent.capabilities.join(', ') : 'none';
|
|
191
|
+
const status = agent.status || 'idle';
|
|
192
|
+
lines.push(this.fieldLine('Model', agent.model || 'default', inner));
|
|
193
|
+
lines.push(this.fieldLine('Read-only', readOnly, inner));
|
|
194
|
+
lines.push(this.fieldLine('Description', agent.description || 'No description', inner));
|
|
195
|
+
lines.push(this.fieldLine('Capabilities', capabilities, inner));
|
|
196
|
+
lines.push(this.fieldLine('Status', status, inner));
|
|
197
|
+
lines.push(this.contentLine('', inner));
|
|
198
|
+
lines.push(this.contentLine(this.theme.fg('dim', ' [r] Run agent [Esc] Back'), inner));
|
|
199
|
+
lines.push(buildBottomBorder(width));
|
|
200
|
+
return lines;
|
|
201
|
+
}
|
|
202
|
+
fieldLine(label, value, innerWidth) {
|
|
203
|
+
const labelText = this.theme.fg('dim', ` ${label}:`);
|
|
204
|
+
const content = `${labelText} ${this.theme.fg('text', value)}`;
|
|
205
|
+
return this.contentLine(content, innerWidth);
|
|
206
|
+
}
|
|
207
|
+
contentLine(content, innerWidth) {
|
|
208
|
+
return `│${padRight(content, innerWidth)}│`;
|
|
209
|
+
}
|
|
210
|
+
getVisibleRange(windowSize) {
|
|
211
|
+
const count = this.agents.length;
|
|
212
|
+
const ws = windowSize ?? this.listWindowSize;
|
|
213
|
+
if (count <= ws)
|
|
214
|
+
return [0, count];
|
|
215
|
+
const half = Math.floor(ws / 2);
|
|
216
|
+
let start = Math.max(0, this.selectedIndex - half);
|
|
217
|
+
let end = start + ws;
|
|
218
|
+
if (end > count) {
|
|
219
|
+
end = count;
|
|
220
|
+
start = Math.max(0, end - ws);
|
|
221
|
+
}
|
|
222
|
+
return [start, end];
|
|
223
|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UAAkB;QACtD,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC;IAC7C,CAAC;IAEO,eAAe,CAAC,UAAmB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACjC,MAAM,EAAE,GAAG,UAAU,IAAI,IAAI,CAAC,cAAc,CAAC;QAC7C,IAAI,KAAK,IAAI,EAAE;YAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAEnC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAChC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;QACnD,IAAI,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC;QAErB,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;YACjB,GAAG,GAAG,KAAK,CAAC;YACZ,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrB,CAAC;CACD"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export interface HubToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: Record<string, unknown>;
|
|
6
|
+
promptSnippet?: string;
|
|
7
|
+
promptGuidelines?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Command definition sent by Hub for agent routing slash commands. */
|
|
10
|
+
export interface HubCommandDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
tools?: string[];
|
|
20
|
+
temperature?: number;
|
|
21
|
+
thinkingLevel?: string;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
hubTools?: HubToolDefinition[];
|
|
24
|
+
capabilities?: string[];
|
|
25
|
+
status?: 'available' | 'busy' | 'offline';
|
|
26
|
+
}
|
|
27
|
+
export interface HubConfig {
|
|
28
|
+
systemPromptPrefix?: string;
|
|
29
|
+
systemPromptSuffix?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface InitMessage {
|
|
32
|
+
type: 'init';
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
tools?: HubToolDefinition[];
|
|
35
|
+
commands?: HubCommandDefinition[];
|
|
36
|
+
agents?: AgentDefinition[];
|
|
37
|
+
config?: HubConfig;
|
|
38
|
+
}
|
|
39
|
+
export interface EventRequest {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'event';
|
|
42
|
+
event: string;
|
|
43
|
+
data: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export interface ToolRequest {
|
|
46
|
+
id: string;
|
|
47
|
+
type: 'tool';
|
|
48
|
+
name: string;
|
|
49
|
+
toolCallId: string;
|
|
50
|
+
params: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/** Command request (Client -> Server) for slash command execution. */
|
|
53
|
+
export interface CommandRequest {
|
|
54
|
+
id: string;
|
|
55
|
+
type: 'command';
|
|
56
|
+
name: string;
|
|
57
|
+
args: string;
|
|
58
|
+
}
|
|
59
|
+
export type HubRequest = EventRequest | ToolRequest | CommandRequest;
|
|
60
|
+
export interface AckAction {
|
|
61
|
+
action: 'ACK';
|
|
62
|
+
}
|
|
63
|
+
export interface BlockAction {
|
|
64
|
+
action: 'BLOCK';
|
|
65
|
+
reason: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ConfirmAction {
|
|
68
|
+
action: 'CONFIRM';
|
|
69
|
+
title: string;
|
|
70
|
+
message: string;
|
|
71
|
+
deny_reason?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface NotifyAction {
|
|
74
|
+
action: 'NOTIFY';
|
|
75
|
+
message: string;
|
|
76
|
+
level?: 'info' | 'warning' | 'error';
|
|
77
|
+
}
|
|
78
|
+
export interface ReturnAction {
|
|
79
|
+
action: 'RETURN';
|
|
80
|
+
result: unknown;
|
|
81
|
+
}
|
|
82
|
+
export interface StatusAction {
|
|
83
|
+
action: 'STATUS';
|
|
84
|
+
key: string;
|
|
85
|
+
text?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SystemPromptAction {
|
|
88
|
+
action: 'SYSTEM_PROMPT';
|
|
89
|
+
systemPrompt: string;
|
|
90
|
+
mode?: 'replace' | 'prefix' | 'suffix';
|
|
91
|
+
}
|
|
92
|
+
export interface InjectMessageAction {
|
|
93
|
+
action: 'INJECT_MESSAGE';
|
|
94
|
+
message: {
|
|
95
|
+
role: 'user' | 'assistant';
|
|
96
|
+
content: string;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export type HubAction = AckAction | BlockAction | ConfirmAction | NotifyAction | ReturnAction | StatusAction | SystemPromptAction | InjectMessageAction;
|
|
100
|
+
/** Progress update from a running sub-agent */
|
|
101
|
+
export interface AgentProgressUpdate {
|
|
102
|
+
agentName: string;
|
|
103
|
+
status: 'running' | 'tool_start' | 'tool_end' | 'completed' | 'failed' | 'thinking_delta' | 'text_delta';
|
|
104
|
+
currentTool?: string;
|
|
105
|
+
currentToolArgs?: string;
|
|
106
|
+
elapsed: number;
|
|
107
|
+
tokens?: {
|
|
108
|
+
input: number;
|
|
109
|
+
output: number;
|
|
110
|
+
cost: number;
|
|
111
|
+
};
|
|
112
|
+
delta?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface HubResponse {
|
|
115
|
+
id: string;
|
|
116
|
+
actions: HubAction[];
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names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EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE;QACR,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;CACF;AAED,MAAM,MAAM,SAAS,GAClB,SAAS,GACT,WAAW,GACX,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,CAAC;AAIvB,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EACH,SAAS,GACT,YAAY,GACZ,UAAU,GACV,WAAW,GACX,QAAQ,GACR,gBAAgB,GAChB,YAAY,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAID,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,SAAS,EAAE,CAAC;CACrB"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,sDAAsD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Session Bridge — TUI ↔ Hub ↔ Sandbox
|
|
3
|
+
*
|
|
4
|
+
* Handles the WebSocket connection and RPC protocol bridge for remote mode.
|
|
5
|
+
* In remote mode, the local Pi TUI connects to an existing sandbox session
|
|
6
|
+
* through the Hub, acting as a thin client:
|
|
7
|
+
* - User input → rpc_command → Hub → sandbox
|
|
8
|
+
* - Sandbox events → rpc_event → Hub → TUI rendering
|
|
9
|
+
* - Extension UI dialogs → rpc_ui_request/response → Hub ↔ TUI
|
|
10
|
+
*
|
|
11
|
+
* This module manages the connection lifecycle and provides an API
|
|
12
|
+
* for the extension to send commands and receive events.
|
|
13
|
+
*/
|
|
14
|
+
import type { ExtensionAPI, ExtensionContext } from '@mariozechner/pi-coding-agent';
|
|
15
|
+
export interface RpcCommand {
|
|
16
|
+
type: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface RpcEvent {
|
|
20
|
+
type: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface RpcUiRequest {
|
|
24
|
+
id: string;
|
|
25
|
+
method: string;
|
|
26
|
+
params: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/** RPC response from sandbox (correlated by id) */
|
|
29
|
+
export interface RpcResponse {
|
|
30
|
+
type: 'response';
|
|
31
|
+
id: string;
|
|
32
|
+
command: string;
|
|
33
|
+
success: boolean;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
export type RemoteEventHandler = (event: RpcEvent) => void;
|
|
38
|
+
export type RemoteResponseHandler = (response: RpcResponse) => void;
|
|
39
|
+
export type RemoteUiHandler = (request: RpcUiRequest) => Promise<unknown>;
|
|
40
|
+
export type RemoteConnectionHandler = (state: 'connected' | 'reconnecting' | 'disconnected') => void;
|
|
41
|
+
export declare class RemoteSession {
|
|
42
|
+
private ws;
|
|
43
|
+
private connected;
|
|
44
|
+
private intentionallyClosed;
|
|
45
|
+
private hubWsUrl;
|
|
46
|
+
private reconnectAttempts;
|
|
47
|
+
private reconnectTimer;
|
|
48
|
+
private eventHandlers;
|
|
49
|
+
private uiHandler;
|
|
50
|
+
private responseHandlers;
|
|
51
|
+
private connectionHandlers;
|
|
52
|
+
/** Session ID this client is connected to */
|
|
53
|
+
sessionId: string;
|
|
54
|
+
/** Session label (populated after connection) */
|
|
55
|
+
label: string;
|
|
56
|
+
/** API key for Hub authentication */
|
|
57
|
+
apiKey: string | null;
|
|
58
|
+
constructor(sessionId: string);
|
|
59
|
+
private dispatchEvent;
|
|
60
|
+
private dispatchResponse;
|
|
61
|
+
/** Register a handler for RPC events from the sandbox */
|
|
62
|
+
onEvent(handler: RemoteEventHandler): void;
|
|
63
|
+
/** Register a handler for RPC responses from the sandbox */
|
|
64
|
+
onResponse(handler: RemoteResponseHandler): void;
|
|
65
|
+
/** Register the UI dialog handler (select, confirm, input, editor) */
|
|
66
|
+
setUiHandler(handler: RemoteUiHandler): void;
|
|
67
|
+
/** Register a connection state change handler */
|
|
68
|
+
onConnectionChange(handler: RemoteConnectionHandler): void;
|
|
69
|
+
/** Connect to the Hub WebSocket as a controller for the remote session */
|
|
70
|
+
connect(hubWsUrl: string): Promise<void>;
|
|
71
|
+
private doConnect;
|
|
72
|
+
private scheduleReconnect;
|
|
73
|
+
private notifyConnectionChange;
|
|
74
|
+
/** Send an RPC command to the sandbox (prompt, steer, abort, etc.) */
|
|
75
|
+
sendCommand(command: RpcCommand): void;
|
|
76
|
+
/** Send a user prompt to the remote sandbox */
|
|
77
|
+
prompt(message: string, images?: string[]): void;
|
|
78
|
+
/** Steer the agent mid-turn */
|
|
79
|
+
steer(message: string): void;
|
|
80
|
+
/** Abort current operation */
|
|
81
|
+
abort(): void;
|
|
82
|
+
/** Get current session state */
|
|
83
|
+
getState(): void;
|
|
84
|
+
/** Get all messages in current session */
|
|
85
|
+
getMessages(): void;
|
|
86
|
+
/** Compact the session context */
|
|
87
|
+
compact(): void;
|
|
88
|
+
/** Close the connection */
|
|
89
|
+
close(): void;
|
|
90
|
+
get isConnected(): boolean;
|
|
91
|
+
/** Handle UI request from sandbox — delegate to registered handler */
|
|
92
|
+
private handleUiRequest;
|
|
93
|
+
/** Send UI response back to sandbox */
|
|
94
|
+
private sendUiResponse;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Set up remote mode for the Pi extension.
|
|
98
|
+
*
|
|
99
|
+
* Connects to an existing sandbox session through the Hub and bridges
|
|
100
|
+
* user input → RPC commands and sandbox events → TUI rendering.
|
|
101
|
+
*
|
|
102
|
+
* Uses Pi's extension APIs for rich rendering:
|
|
103
|
+
* - pi.sendMessage() for completed assistant messages
|
|
104
|
+
* - ctx.ui.setWidget() for streaming output
|
|
105
|
+
* - ctx.ui.setWorkingMessage() for tool execution status
|
|
106
|
+
* - ctx.ui.setStatus() for connection and agent state
|
|
107
|
+
*/
|
|
108
|
+
export declare function setupRemoteMode(pi: ExtensionAPI, hubWsUrl: string, sessionId: string): Promise<RemoteSession>;
|
|
109
|
+
/** Internal interface for passing extension context to RemoteSession */
|
|
110
|
+
export interface RemoteSessionInternal extends RemoteSession {
|
|
111
|
+
_setExtensionCtx?: (ctx: ExtensionContext) => void;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=remote-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session.d.ts","sourceRoot":"","sources":["../src/remote-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAUpF,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE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