agent-relay 2.0.32 → 2.0.34
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 +44 -0
- package/dist/index.cjs +7231 -6234
- package/package.json +19 -18
- package/packages/api-types/.trajectories/active/traj_xbsvuzogscey.json +15 -0
- package/packages/api-types/.trajectories/index.json +12 -0
- package/packages/api-types/package.json +1 -1
- package/packages/benchmark/package.json +4 -4
- package/packages/bridge/dist/spawner.d.ts.map +1 -1
- package/packages/bridge/dist/spawner.js +127 -0
- package/packages/bridge/dist/spawner.js.map +1 -1
- package/packages/bridge/package.json +8 -8
- package/packages/bridge/src/spawner.ts +137 -0
- package/packages/cli-tester/package.json +1 -1
- package/packages/config/package.json +2 -2
- package/packages/continuity/package.json +1 -1
- package/packages/daemon/package.json +12 -12
- package/packages/hooks/package.json +4 -4
- package/packages/mcp/package.json +3 -3
- package/packages/memory/package.json +2 -2
- package/packages/policy/package.json +2 -2
- package/packages/protocol/package.json +1 -1
- package/packages/resiliency/package.json +1 -1
- package/packages/sdk/package.json +2 -2
- package/packages/spawner/package.json +1 -1
- package/packages/state/package.json +1 -1
- package/packages/storage/package.json +2 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +2 -2
- package/packages/wrapper/dist/base-wrapper.d.ts.map +1 -1
- package/packages/wrapper/dist/base-wrapper.js +27 -7
- package/packages/wrapper/dist/base-wrapper.js.map +1 -1
- package/packages/wrapper/dist/client.d.ts +27 -0
- package/packages/wrapper/dist/client.d.ts.map +1 -1
- package/packages/wrapper/dist/client.js +116 -0
- package/packages/wrapper/dist/client.js.map +1 -1
- package/packages/wrapper/dist/index.d.ts +3 -0
- package/packages/wrapper/dist/index.d.ts.map +1 -1
- package/packages/wrapper/dist/index.js +6 -0
- package/packages/wrapper/dist/index.js.map +1 -1
- package/packages/wrapper/dist/opencode-api.d.ts +106 -0
- package/packages/wrapper/dist/opencode-api.d.ts.map +1 -0
- package/packages/wrapper/dist/opencode-api.js +219 -0
- package/packages/wrapper/dist/opencode-api.js.map +1 -0
- package/packages/wrapper/dist/opencode-wrapper.d.ts +157 -0
- package/packages/wrapper/dist/opencode-wrapper.d.ts.map +1 -0
- package/packages/wrapper/dist/opencode-wrapper.js +414 -0
- package/packages/wrapper/dist/opencode-wrapper.js.map +1 -0
- package/packages/wrapper/dist/relay-pty-orchestrator.d.ts.map +1 -1
- package/packages/wrapper/dist/relay-pty-orchestrator.js +18 -0
- package/packages/wrapper/dist/relay-pty-orchestrator.js.map +1 -1
- package/packages/wrapper/dist/wrapper-events.d.ts +489 -0
- package/packages/wrapper/dist/wrapper-events.d.ts.map +1 -0
- package/packages/wrapper/dist/wrapper-events.js +252 -0
- package/packages/wrapper/dist/wrapper-events.js.map +1 -0
- package/packages/wrapper/package.json +7 -6
- package/packages/wrapper/src/base-wrapper.ts +23 -7
- package/packages/wrapper/src/client.test.ts +92 -3
- package/packages/wrapper/src/client.ts +163 -0
- package/packages/wrapper/src/index.ts +29 -0
- package/packages/wrapper/src/opencode-api.test.ts +292 -0
- package/packages/wrapper/src/opencode-api.ts +285 -0
- package/packages/wrapper/src/opencode-wrapper.ts +513 -0
- package/packages/wrapper/src/relay-pty-orchestrator.test.ts +176 -0
- package/packages/wrapper/src/relay-pty-orchestrator.ts +20 -0
- package/packages/wrapper/src/wrapper-events.ts +395 -0
- package/scripts/postinstall.js +147 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCodeWrapper - Wrapper for opencode CLI with HTTP API support
|
|
3
|
+
*
|
|
4
|
+
* This wrapper supports two modes of message injection:
|
|
5
|
+
* 1. HTTP API mode: Uses opencode serve's /tui/append-prompt endpoint
|
|
6
|
+
* 2. PTY fallback: Falls back to PTY-based injection when HTTP is unavailable
|
|
7
|
+
*
|
|
8
|
+
* The wrapper automatically detects which mode to use based on:
|
|
9
|
+
* - Whether `opencode serve` is running (checks localhost:4096)
|
|
10
|
+
* - Configuration options (httpApi.enabled, httpApi.fallbackToPty)
|
|
11
|
+
*
|
|
12
|
+
* Usage with HTTP API:
|
|
13
|
+
* ```
|
|
14
|
+
* const wrapper = new OpenCodeWrapper({
|
|
15
|
+
* name: 'MyAgent',
|
|
16
|
+
* command: 'opencode',
|
|
17
|
+
* httpApi: {
|
|
18
|
+
* enabled: true,
|
|
19
|
+
* baseUrl: 'http://localhost:4096',
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
* await wrapper.start();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/anomalyco/opencode
|
|
26
|
+
*/
|
|
27
|
+
import { BaseWrapper, type BaseWrapperConfig } from './base-wrapper.js';
|
|
28
|
+
import { OpenCodeApi, type OpenCodeApiConfig } from './opencode-api.js';
|
|
29
|
+
export interface OpenCodeWrapperConfig extends BaseWrapperConfig {
|
|
30
|
+
/** HTTP API configuration */
|
|
31
|
+
httpApi?: OpenCodeApiConfig & {
|
|
32
|
+
/** Enable HTTP API mode (default: true when wrapping opencode) */
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** Fall back to PTY injection if HTTP is unavailable (default: true) */
|
|
35
|
+
fallbackToPty?: boolean;
|
|
36
|
+
/** Auto-start opencode serve if not running (default: false) */
|
|
37
|
+
autoStartServe?: boolean;
|
|
38
|
+
/** Wait for serve to be available in milliseconds (default: 5000) */
|
|
39
|
+
waitForServeMs?: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wrapper for opencode CLI with HTTP API support
|
|
44
|
+
*/
|
|
45
|
+
export declare class OpenCodeWrapper extends BaseWrapper {
|
|
46
|
+
protected config: OpenCodeWrapperConfig;
|
|
47
|
+
private api;
|
|
48
|
+
private httpApiAvailable;
|
|
49
|
+
private process?;
|
|
50
|
+
private outputBuffer;
|
|
51
|
+
private parser;
|
|
52
|
+
private serveProcess?;
|
|
53
|
+
constructor(config: OpenCodeWrapperConfig);
|
|
54
|
+
start(): Promise<void>;
|
|
55
|
+
stop(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Start in HTTP API mode
|
|
58
|
+
* In this mode, we don't spawn opencode ourselves - we communicate via HTTP API
|
|
59
|
+
*/
|
|
60
|
+
private startHttpMode;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe to opencode SSE events for output parsing
|
|
63
|
+
*/
|
|
64
|
+
private subscribeToEvents;
|
|
65
|
+
/**
|
|
66
|
+
* Start in PTY mode (fallback when HTTP is unavailable)
|
|
67
|
+
*/
|
|
68
|
+
private startPtyMode;
|
|
69
|
+
/**
|
|
70
|
+
* Handle output from opencode (either via SSE or PTY)
|
|
71
|
+
*/
|
|
72
|
+
private handleOutput;
|
|
73
|
+
/**
|
|
74
|
+
* Handle a parsed relay command
|
|
75
|
+
*/
|
|
76
|
+
private handleParsedCommand;
|
|
77
|
+
protected performInjection(content: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Inject content via HTTP API
|
|
80
|
+
*/
|
|
81
|
+
private performHttpInjection;
|
|
82
|
+
/**
|
|
83
|
+
* Inject content via PTY stdin
|
|
84
|
+
*/
|
|
85
|
+
private performPtyInjection;
|
|
86
|
+
protected getCleanOutput(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Auto-start opencode serve
|
|
89
|
+
*/
|
|
90
|
+
private startServe;
|
|
91
|
+
/**
|
|
92
|
+
* Process the message queue
|
|
93
|
+
* Override to use HTTP API's direct injection when available
|
|
94
|
+
*/
|
|
95
|
+
protected processMessageQueue(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the process ID (undefined in HTTP mode, defined in PTY mode)
|
|
98
|
+
*/
|
|
99
|
+
get pid(): number | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Log path (not applicable for OpenCodeWrapper)
|
|
102
|
+
*/
|
|
103
|
+
get logPath(): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Kill the wrapper (alias for stop())
|
|
106
|
+
*/
|
|
107
|
+
kill(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Write to the process stdin (PTY mode only)
|
|
110
|
+
*/
|
|
111
|
+
write(data: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Inject a task into the agent
|
|
114
|
+
* @param task - The task description to inject
|
|
115
|
+
* @param _from - The sender name (used for formatting)
|
|
116
|
+
* @returns true if injection succeeded
|
|
117
|
+
*/
|
|
118
|
+
injectTask(task: string, _from?: string): Promise<boolean>;
|
|
119
|
+
/**
|
|
120
|
+
* Get output lines (for compatibility with spawner)
|
|
121
|
+
*/
|
|
122
|
+
getOutput(limit?: number): string[];
|
|
123
|
+
/**
|
|
124
|
+
* Get raw output (for compatibility with spawner)
|
|
125
|
+
*/
|
|
126
|
+
getRawOutput(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Wait until the wrapper is ready to receive messages
|
|
129
|
+
* In HTTP mode, this checks if the API is available
|
|
130
|
+
* In PTY mode, this waits for the process to start
|
|
131
|
+
*/
|
|
132
|
+
waitUntilReadyForMessages(timeoutMs?: number, _pollMs?: number): Promise<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Wait until CLI is ready (alias for waitUntilReadyForMessages)
|
|
135
|
+
*/
|
|
136
|
+
waitUntilCliReady(timeoutMs?: number, pollMs?: number): Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* Check if HTTP API mode is active
|
|
139
|
+
*/
|
|
140
|
+
get isHttpApiMode(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Get the OpenCode API client for advanced operations
|
|
143
|
+
*/
|
|
144
|
+
get openCodeApi(): OpenCodeApi;
|
|
145
|
+
/**
|
|
146
|
+
* Switch to a specific session
|
|
147
|
+
*/
|
|
148
|
+
switchSession(sessionId: string): Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* List available sessions
|
|
151
|
+
*/
|
|
152
|
+
listSessions(): Promise<{
|
|
153
|
+
id: string;
|
|
154
|
+
title?: string;
|
|
155
|
+
}[]>;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=opencode-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-wrapper.d.ts","sourceRoot":"","sources":["../src/opencode-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAIxE,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,6BAA6B;IAC7B,OAAO,CAAC,EAAE,iBAAiB,GAAG;QAC5B,kEAAkE;QAClE,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,wEAAwE;QACxE,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gEAAgE;QAChE,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,qEAAqE;QACrE,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,UAAmB,MAAM,EAAE,qBAAqB,CAAC;IAGjD,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,gBAAgB,CAAS;IAGjC,OAAO,CAAC,OAAO,CAAC,CAAe;IAC/B,OAAO,CAAC,YAAY,CAAM;IAG1B,OAAO,CAAC,MAAM,CAAe;IAG7B,OAAO,CAAC,YAAY,CAAC,CAAe;gBAExB,MAAM,EAAE,qBAAqB;IAsBnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqCtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB3B;;;OAGG;YACW,aAAa;IAa3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAyBzB;;OAEG;YACW,YAAY;IAsC1B;;OAEG;I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E,MAAM,CAAA;KAAE,EAAE,CAAC;CAShE"}
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCodeWrapper - Wrapper for opencode CLI with HTTP API support
|
|
3
|
+
*
|
|
4
|
+
* This wrapper supports two modes of message injection:
|
|
5
|
+
* 1. HTTP API mode: Uses opencode serve's /tui/append-prompt endpoint
|
|
6
|
+
* 2. PTY fallback: Falls back to PTY-based injection when HTTP is unavailable
|
|
7
|
+
*
|
|
8
|
+
* The wrapper automatically detects which mode to use based on:
|
|
9
|
+
* - Whether `opencode serve` is running (checks localhost:4096)
|
|
10
|
+
* - Configuration options (httpApi.enabled, httpApi.fallbackToPty)
|
|
11
|
+
*
|
|
12
|
+
* Usage with HTTP API:
|
|
13
|
+
* ```
|
|
14
|
+
* const wrapper = new OpenCodeWrapper({
|
|
15
|
+
* name: 'MyAgent',
|
|
16
|
+
* command: 'opencode',
|
|
17
|
+
* httpApi: {
|
|
18
|
+
* enabled: true,
|
|
19
|
+
* baseUrl: 'http://localhost:4096',
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
* await wrapper.start();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/anomalyco/opencode
|
|
26
|
+
*/
|
|
27
|
+
import { spawn } from 'node:child_process';
|
|
28
|
+
import { BaseWrapper } from './base-wrapper.js';
|
|
29
|
+
import { OpenCodeApi } from './opencode-api.js';
|
|
30
|
+
import { OutputParser } from './parser.js';
|
|
31
|
+
import { buildInjectionString } from './shared.js';
|
|
32
|
+
/**
|
|
33
|
+
* Wrapper for opencode CLI with HTTP API support
|
|
34
|
+
*/
|
|
35
|
+
export class OpenCodeWrapper extends BaseWrapper {
|
|
36
|
+
config;
|
|
37
|
+
// OpenCode API client
|
|
38
|
+
api;
|
|
39
|
+
httpApiAvailable = false;
|
|
40
|
+
// Process management (for PTY fallback mode)
|
|
41
|
+
process;
|
|
42
|
+
outputBuffer = '';
|
|
43
|
+
// Output parser for relay commands
|
|
44
|
+
parser;
|
|
45
|
+
// Serve process (if auto-started)
|
|
46
|
+
serveProcess;
|
|
47
|
+
constructor(config) {
|
|
48
|
+
// Default to opencode CLI type
|
|
49
|
+
super({ ...config, cliType: config.cliType ?? 'opencode' });
|
|
50
|
+
this.config = config;
|
|
51
|
+
// Initialize API client
|
|
52
|
+
this.api = new OpenCodeApi({
|
|
53
|
+
baseUrl: config.httpApi?.baseUrl,
|
|
54
|
+
password: config.httpApi?.password,
|
|
55
|
+
timeout: config.httpApi?.timeout,
|
|
56
|
+
});
|
|
57
|
+
// Initialize parser with relay prefix
|
|
58
|
+
this.parser = new OutputParser({
|
|
59
|
+
prefix: this.relayPrefix,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// =========================================================================
|
|
63
|
+
// Lifecycle
|
|
64
|
+
// =========================================================================
|
|
65
|
+
async start() {
|
|
66
|
+
if (this.running)
|
|
67
|
+
return;
|
|
68
|
+
// Try to use HTTP API mode first (if enabled)
|
|
69
|
+
if (this.config.httpApi?.enabled !== false) {
|
|
70
|
+
// Check if opencode serve is available
|
|
71
|
+
this.httpApiAvailable = await this.api.isAvailable();
|
|
72
|
+
if (!this.httpApiAvailable && this.config.httpApi?.autoStartServe) {
|
|
73
|
+
// Auto-start opencode serve
|
|
74
|
+
await this.startServe();
|
|
75
|
+
this.httpApiAvailable = await this.api.waitForAvailable(this.config.httpApi?.waitForServeMs ?? 5000);
|
|
76
|
+
}
|
|
77
|
+
if (this.httpApiAvailable) {
|
|
78
|
+
console.log('[OpenCodeWrapper] Using HTTP API mode');
|
|
79
|
+
await this.startHttpMode();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Check if we should fall back to PTY
|
|
83
|
+
if (this.config.httpApi?.fallbackToPty === false) {
|
|
84
|
+
throw new Error('OpenCode serve is not available and fallbackToPty is disabled. ' +
|
|
85
|
+
'Start opencode serve or enable fallbackToPty.');
|
|
86
|
+
}
|
|
87
|
+
console.log('[OpenCodeWrapper] HTTP API unavailable, falling back to PTY mode');
|
|
88
|
+
}
|
|
89
|
+
// Fall back to PTY mode
|
|
90
|
+
await this.startPtyMode();
|
|
91
|
+
}
|
|
92
|
+
async stop() {
|
|
93
|
+
this.running = false;
|
|
94
|
+
// Disconnect from relay daemon
|
|
95
|
+
this.client.disconnect();
|
|
96
|
+
// Stop the main process
|
|
97
|
+
if (this.process) {
|
|
98
|
+
this.process.kill();
|
|
99
|
+
this.process = undefined;
|
|
100
|
+
}
|
|
101
|
+
// Stop the serve process if we started it
|
|
102
|
+
if (this.serveProcess) {
|
|
103
|
+
this.serveProcess.kill();
|
|
104
|
+
this.serveProcess = undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// =========================================================================
|
|
108
|
+
// HTTP API Mode
|
|
109
|
+
// =========================================================================
|
|
110
|
+
/**
|
|
111
|
+
* Start in HTTP API mode
|
|
112
|
+
* In this mode, we don't spawn opencode ourselves - we communicate via HTTP API
|
|
113
|
+
*/
|
|
114
|
+
async startHttpMode() {
|
|
115
|
+
this.running = true;
|
|
116
|
+
// Connect to relay daemon
|
|
117
|
+
await this.client.connect();
|
|
118
|
+
// Subscribe to opencode events for output parsing
|
|
119
|
+
this.subscribeToEvents();
|
|
120
|
+
// Show a toast to indicate relay is connected
|
|
121
|
+
await this.api.showToast('Agent Relay connected', { variant: 'success', duration: 2000 });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Subscribe to opencode SSE events for output parsing
|
|
125
|
+
*/
|
|
126
|
+
subscribeToEvents() {
|
|
127
|
+
this.api.subscribeToEvents(event => {
|
|
128
|
+
// Parse events for relay commands
|
|
129
|
+
if (event.type === 'message' || event.type === 'assistant_message') {
|
|
130
|
+
const content = typeof event.data === 'string' ? event.data : JSON.stringify(event.data);
|
|
131
|
+
this.handleOutput(content);
|
|
132
|
+
}
|
|
133
|
+
}, error => {
|
|
134
|
+
console.error('[OpenCodeWrapper] SSE error:', error.message);
|
|
135
|
+
// Attempt to reconnect after a delay
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
if (this.running && this.httpApiAvailable) {
|
|
138
|
+
this.subscribeToEvents();
|
|
139
|
+
}
|
|
140
|
+
}, 5000);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// =========================================================================
|
|
144
|
+
// PTY Fallback Mode
|
|
145
|
+
// =========================================================================
|
|
146
|
+
/**
|
|
147
|
+
* Start in PTY mode (fallback when HTTP is unavailable)
|
|
148
|
+
*/
|
|
149
|
+
async startPtyMode() {
|
|
150
|
+
this.running = true;
|
|
151
|
+
// Connect to relay daemon
|
|
152
|
+
await this.client.connect();
|
|
153
|
+
// Spawn opencode process
|
|
154
|
+
const args = this.config.args ?? [];
|
|
155
|
+
this.process = spawn(this.config.command, args, {
|
|
156
|
+
cwd: this.config.cwd,
|
|
157
|
+
env: { ...process.env, ...this.config.env },
|
|
158
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
159
|
+
});
|
|
160
|
+
// Handle stdout
|
|
161
|
+
this.process.stdout?.on('data', (data) => {
|
|
162
|
+
const text = data.toString();
|
|
163
|
+
this.outputBuffer += text;
|
|
164
|
+
this.handleOutput(text);
|
|
165
|
+
});
|
|
166
|
+
// Handle stderr
|
|
167
|
+
this.process.stderr?.on('data', (data) => {
|
|
168
|
+
const text = data.toString();
|
|
169
|
+
this.outputBuffer += text;
|
|
170
|
+
});
|
|
171
|
+
// Handle exit
|
|
172
|
+
this.process.on('exit', (code, signal) => {
|
|
173
|
+
this.running = false;
|
|
174
|
+
this.emit('exit', code, signal);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// =========================================================================
|
|
178
|
+
// Output Handling
|
|
179
|
+
// =========================================================================
|
|
180
|
+
/**
|
|
181
|
+
* Handle output from opencode (either via SSE or PTY)
|
|
182
|
+
*/
|
|
183
|
+
handleOutput(text) {
|
|
184
|
+
// Feed to idle detector
|
|
185
|
+
this.idleDetector.onOutput(text);
|
|
186
|
+
// Feed to stuck detector
|
|
187
|
+
this.stuckDetector.onOutput(text);
|
|
188
|
+
// Parse for relay commands
|
|
189
|
+
const result = this.parser.parse(text);
|
|
190
|
+
for (const cmd of result.commands) {
|
|
191
|
+
this.handleParsedCommand(cmd);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Handle a parsed relay command
|
|
196
|
+
*/
|
|
197
|
+
handleParsedCommand(cmd) {
|
|
198
|
+
// Send message via relay client
|
|
199
|
+
this.client.sendMessage(cmd.to, cmd.body, cmd.kind, cmd.data, cmd.thread);
|
|
200
|
+
}
|
|
201
|
+
// =========================================================================
|
|
202
|
+
// Message Injection
|
|
203
|
+
// =========================================================================
|
|
204
|
+
async performInjection(content) {
|
|
205
|
+
if (this.httpApiAvailable) {
|
|
206
|
+
await this.performHttpInjection(content);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
await this.performPtyInjection(content);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Inject content via HTTP API
|
|
214
|
+
*/
|
|
215
|
+
async performHttpInjection(content) {
|
|
216
|
+
const result = await this.api.appendPrompt(content);
|
|
217
|
+
if (!result.success) {
|
|
218
|
+
throw new Error(`HTTP injection failed: ${result.error}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Inject content via PTY stdin
|
|
223
|
+
*/
|
|
224
|
+
async performPtyInjection(content) {
|
|
225
|
+
if (!this.process?.stdin) {
|
|
226
|
+
throw new Error('PTY stdin not available');
|
|
227
|
+
}
|
|
228
|
+
// Write to stdin
|
|
229
|
+
this.process.stdin.write(content + '\n');
|
|
230
|
+
}
|
|
231
|
+
getCleanOutput() {
|
|
232
|
+
return this.outputBuffer;
|
|
233
|
+
}
|
|
234
|
+
// =========================================================================
|
|
235
|
+
// Serve Process Management
|
|
236
|
+
// =========================================================================
|
|
237
|
+
/**
|
|
238
|
+
* Auto-start opencode serve
|
|
239
|
+
*/
|
|
240
|
+
async startServe() {
|
|
241
|
+
console.log('[OpenCodeWrapper] Auto-starting opencode serve...');
|
|
242
|
+
this.serveProcess = spawn('opencode', ['serve'], {
|
|
243
|
+
cwd: this.config.cwd,
|
|
244
|
+
env: { ...process.env, ...this.config.env },
|
|
245
|
+
stdio: 'ignore',
|
|
246
|
+
detached: true,
|
|
247
|
+
});
|
|
248
|
+
// Don't wait for serve process - it runs in background
|
|
249
|
+
this.serveProcess.unref();
|
|
250
|
+
}
|
|
251
|
+
// =========================================================================
|
|
252
|
+
// Message Queue Processing (override for HTTP mode optimization)
|
|
253
|
+
// =========================================================================
|
|
254
|
+
/**
|
|
255
|
+
* Process the message queue
|
|
256
|
+
* Override to use HTTP API's direct injection when available
|
|
257
|
+
*/
|
|
258
|
+
async processMessageQueue() {
|
|
259
|
+
if (this.isInjecting || this.messageQueue.length === 0) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
// Check if we should wait for idle (only in PTY mode)
|
|
263
|
+
if (!this.httpApiAvailable) {
|
|
264
|
+
const idleResult = this.idleDetector.checkIdle();
|
|
265
|
+
if (!idleResult.isIdle) {
|
|
266
|
+
// In PTY mode, wait for idle before injection
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
this.isInjecting = true;
|
|
271
|
+
try {
|
|
272
|
+
// Sort by importance (higher first) and process
|
|
273
|
+
const sortedQueue = [...this.messageQueue].sort((a, b) => (b.importance ?? 0) - (a.importance ?? 0));
|
|
274
|
+
for (const msg of sortedQueue) {
|
|
275
|
+
const injectionString = buildInjectionString(msg);
|
|
276
|
+
await this.performInjection(injectionString);
|
|
277
|
+
// Remove from queue
|
|
278
|
+
const index = this.messageQueue.indexOf(msg);
|
|
279
|
+
if (index !== -1) {
|
|
280
|
+
this.messageQueue.splice(index, 1);
|
|
281
|
+
}
|
|
282
|
+
// Update metrics
|
|
283
|
+
this.injectionMetrics.successFirstTry++;
|
|
284
|
+
this.injectionMetrics.total++;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
this.injectionMetrics.failed++;
|
|
289
|
+
this.injectionMetrics.total++;
|
|
290
|
+
console.error('[OpenCodeWrapper] Injection error:', error);
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
this.isInjecting = false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// =========================================================================
|
|
297
|
+
// Spawner Compatibility Methods
|
|
298
|
+
// =========================================================================
|
|
299
|
+
/**
|
|
300
|
+
* Get the process ID (undefined in HTTP mode, defined in PTY mode)
|
|
301
|
+
*/
|
|
302
|
+
get pid() {
|
|
303
|
+
return this.process?.pid;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Log path (not applicable for OpenCodeWrapper)
|
|
307
|
+
*/
|
|
308
|
+
get logPath() {
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Kill the wrapper (alias for stop())
|
|
313
|
+
*/
|
|
314
|
+
async kill() {
|
|
315
|
+
await this.stop();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Write to the process stdin (PTY mode only)
|
|
319
|
+
*/
|
|
320
|
+
write(data) {
|
|
321
|
+
if (this.process?.stdin) {
|
|
322
|
+
this.process.stdin.write(data);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Inject a task into the agent
|
|
327
|
+
* @param task - The task description to inject
|
|
328
|
+
* @param _from - The sender name (used for formatting)
|
|
329
|
+
* @returns true if injection succeeded
|
|
330
|
+
*/
|
|
331
|
+
async injectTask(task, _from) {
|
|
332
|
+
try {
|
|
333
|
+
await this.performInjection(task);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
console.error('[OpenCodeWrapper] Task injection failed:', error);
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Get output lines (for compatibility with spawner)
|
|
343
|
+
*/
|
|
344
|
+
getOutput(limit) {
|
|
345
|
+
const lines = this.outputBuffer.split('\n');
|
|
346
|
+
return limit ? lines.slice(-limit) : lines;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get raw output (for compatibility with spawner)
|
|
350
|
+
*/
|
|
351
|
+
getRawOutput() {
|
|
352
|
+
return this.outputBuffer;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Wait until the wrapper is ready to receive messages
|
|
356
|
+
* In HTTP mode, this checks if the API is available
|
|
357
|
+
* In PTY mode, this waits for the process to start
|
|
358
|
+
*/
|
|
359
|
+
async waitUntilReadyForMessages(timeoutMs = 15000, _pollMs = 100) {
|
|
360
|
+
if (!this.running) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
if (this.httpApiAvailable) {
|
|
364
|
+
// HTTP mode: check if API responds
|
|
365
|
+
return await this.api.waitForAvailable(timeoutMs);
|
|
366
|
+
}
|
|
367
|
+
// PTY mode: process is ready if stdin is available
|
|
368
|
+
return this.process?.stdin !== null;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Wait until CLI is ready (alias for waitUntilReadyForMessages)
|
|
372
|
+
*/
|
|
373
|
+
async waitUntilCliReady(timeoutMs = 15000, pollMs = 100) {
|
|
374
|
+
return this.waitUntilReadyForMessages(timeoutMs, pollMs);
|
|
375
|
+
}
|
|
376
|
+
// =========================================================================
|
|
377
|
+
// Public API
|
|
378
|
+
// =========================================================================
|
|
379
|
+
/**
|
|
380
|
+
* Check if HTTP API mode is active
|
|
381
|
+
*/
|
|
382
|
+
get isHttpApiMode() {
|
|
383
|
+
return this.httpApiAvailable;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Get the OpenCode API client for advanced operations
|
|
387
|
+
*/
|
|
388
|
+
get openCodeApi() {
|
|
389
|
+
return this.api;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Switch to a specific session
|
|
393
|
+
*/
|
|
394
|
+
async switchSession(sessionId) {
|
|
395
|
+
if (!this.httpApiAvailable) {
|
|
396
|
+
console.warn('[OpenCodeWrapper] Cannot switch sessions in PTY mode');
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
const result = await this.api.selectSession(sessionId);
|
|
400
|
+
return result.success;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* List available sessions
|
|
404
|
+
*/
|
|
405
|
+
async listSessions() {
|
|
406
|
+
if (!this.httpApiAvailable) {
|
|
407
|
+
console.warn('[OpenCodeWrapper] Cannot list sessions in PTY mode');
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
const result = await this.api.listSessions();
|
|
411
|
+
return result.data ?? [];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
//# sourceMappingURL=opencode-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-wrapper.js","sourceRoot":"","sources":["../src/opencode-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAA0B,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAA0B,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAsB,MAAM,aAAa,CAAC;AAgBvE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC3B,MAAM,CAAwB;IAEjD,sBAAsB;IACd,GAAG,CAAc;IACjB,gBAAgB,GAAG,KAAK,CAAC;IAEjC,6CAA6C;IACrC,OAAO,CAAgB;IACvB,YAAY,GAAG,EAAE,CAAC;IAE1B,mCAAmC;IAC3B,MAAM,CAAe;IAE7B,kCA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IACH,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3B;;;OAGG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAQnC;;;OAGG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjD;;;;;;;OAOG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IA0DlE;;OAEG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;CAGjC"}
|
|
@@ -35,6 +35,12 @@ import { getMemoryMonitor, formatBytes, getCgroupManager, } from '@agent-relay/r
|
|
|
35
35
|
// Types for relay-pty socket protocol
|
|
36
36
|
// ============================================================================
|
|
37
37
|
const MAX_SOCKET_PATH_LENGTH = 107;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum size for output buffers (rawBuffer, outputBuffer) in bytes.
|
|
40
|
+
* Prevents RangeError: Invalid string length when agents produce lots of output.
|
|
41
|
+
* Set to 10MB - enough to capture context but won't exhaust memory.
|
|
42
|
+
*/
|
|
43
|
+
const MAX_OUTPUT_BUFFER_SIZE = 10 * 1024 * 1024; // 10MB
|
|
38
44
|
function hashWorkspaceId(workspaceId) {
|
|
39
45
|
return createHash('sha256').update(workspaceId).digest('hex').slice(0, 12);
|
|
40
46
|
}
|
|
@@ -716,6 +722,18 @@ export class RelayPtyOrchestrator extends BaseWrapper {
|
|
|
716
722
|
this.rawBuffer += data;
|
|
717
723
|
this.outputBuffer += data;
|
|
718
724
|
this.hasReceivedOutput = true;
|
|
725
|
+
// Trim buffers if they exceed max size to prevent RangeError: Invalid string length
|
|
726
|
+
// Keep the most recent output (tail) as it's more relevant for pattern matching
|
|
727
|
+
if (this.rawBuffer.length > MAX_OUTPUT_BUFFER_SIZE) {
|
|
728
|
+
const trimAmount = this.rawBuffer.length - MAX_OUTPUT_BUFFER_SIZE;
|
|
729
|
+
this.rawBuffer = this.rawBuffer.slice(-MAX_OUTPUT_BUFFER_SIZE);
|
|
730
|
+
// Adjust lastParsedLength to stay in sync with the trimmed buffer
|
|
731
|
+
// This ensures parseRelayCommands() doesn't skip content or re-parse old content
|
|
732
|
+
this.lastParsedLength = Math.max(0, this.lastParsedLength - trimAmount);
|
|
733
|
+
}
|
|
734
|
+
if (this.outputBuffer.length > MAX_OUTPUT_BUFFER_SIZE) {
|
|
735
|
+
this.outputBuffer = this.outputBuffer.slice(-MAX_OUTPUT_BUFFER_SIZE);
|
|
736
|
+
}
|
|
719
737
|
// Feed to idle detector
|
|
720
738
|
this.feedIdleDetectorOutput(data);
|
|
721
739
|
// Check for unread messages and append indicator if needed
|