wave-code 0.19.2 → 0.19.4
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/stdio/agentBridge.d.ts +80 -0
- package/dist/stdio/agentBridge.d.ts.map +1 -0
- package/dist/stdio/agentBridge.js +562 -0
- package/dist/stdio/index.d.ts +4 -0
- package/dist/stdio/index.d.ts.map +1 -0
- package/dist/stdio/index.js +3 -0
- package/dist/stdio/protocol.d.ts +42 -0
- package/dist/stdio/protocol.d.ts.map +1 -0
- package/dist/stdio/protocol.js +26 -0
- package/dist/stdio/stdioServer.d.ts +34 -0
- package/dist/stdio/stdioServer.d.ts.map +1 -0
- package/dist/stdio/stdioServer.js +127 -0
- package/dist/stdio-cli.d.ts +9 -0
- package/dist/stdio-cli.d.ts.map +1 -0
- package/dist/stdio-cli.js +15 -0
- package/package.json +3 -4
- package/src/index.ts +12 -11
- package/src/stdio/agentBridge.ts +965 -0
- package/src/stdio/index.ts +7 -0
- package/src/stdio/protocol.ts +134 -0
- package/src/stdio/stdioServer.ts +169 -0
- package/src/stdio-cli.ts +18 -0
- package/dist/acp/agent.d.ts +0 -32
- package/dist/acp/agent.d.ts.map +0 -1
- package/dist/acp/agent.js +0 -1163
- package/dist/acp/index.d.ts +0 -2
- package/dist/acp/index.d.ts.map +0 -1
- package/dist/acp/index.js +0 -22
- package/dist/acp-cli.d.ts +0 -2
- package/dist/acp-cli.d.ts.map +0 -1
- package/dist/acp-cli.js +0 -4
- package/src/acp/agent.ts +0 -1501
- package/src/acp/index.ts +0 -28
- package/src/acp-cli.ts +0 -5
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0-compatible protocol types for stdio communication.
|
|
3
|
+
*
|
|
4
|
+
* Each line on stdin/stdout is one JSON object.
|
|
5
|
+
* - Requests have `id` (number|string) and expect a response.
|
|
6
|
+
* - Responses match the request `id` with either `result` or `error`.
|
|
7
|
+
* - Notifications have no `id` and expect no response.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ── Envelope types ──────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export interface JsonRpcRequest {
|
|
13
|
+
id: number | string;
|
|
14
|
+
method: string;
|
|
15
|
+
params?: unknown;
|
|
16
|
+
/** Session-scoped requests carry sessionId for routing to the right Agent. */
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface JsonRpcResponse {
|
|
21
|
+
id: number | string | null;
|
|
22
|
+
result?: unknown;
|
|
23
|
+
error?: JsonRpcError;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface JsonRpcError {
|
|
27
|
+
code: number;
|
|
28
|
+
message: string;
|
|
29
|
+
data?: unknown;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface JsonRpcNotification {
|
|
33
|
+
method: string;
|
|
34
|
+
params?: unknown;
|
|
35
|
+
/** Session-scoped notifications carry sessionId for demultiplexing on the client. */
|
|
36
|
+
sessionId?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ── Error codes (JSON-RPC 2.0 standard) ────────────────────────
|
|
40
|
+
|
|
41
|
+
export const PARSE_ERROR = -32700;
|
|
42
|
+
export const INVALID_REQUEST = -32600;
|
|
43
|
+
export const METHOD_NOT_FOUND = -32601;
|
|
44
|
+
export const INVALID_PARAMS = -32602;
|
|
45
|
+
export const INTERNAL_ERROR = -32603;
|
|
46
|
+
|
|
47
|
+
// ── Client → Server request methods ─────────────────────────────
|
|
48
|
+
|
|
49
|
+
export type RequestMethod =
|
|
50
|
+
| "initialize"
|
|
51
|
+
| "destroy"
|
|
52
|
+
| "restoreSession"
|
|
53
|
+
| "listSessions"
|
|
54
|
+
| "getSessionInfo"
|
|
55
|
+
| "sendMessage"
|
|
56
|
+
| "bang"
|
|
57
|
+
| "abortMessage"
|
|
58
|
+
| "clearMessages"
|
|
59
|
+
| "rewindToMessage"
|
|
60
|
+
| "deleteQueuedMessage"
|
|
61
|
+
| "getMessages"
|
|
62
|
+
| "getFullMessageThread"
|
|
63
|
+
| "setPermissionMode"
|
|
64
|
+
| "getPermissionMode"
|
|
65
|
+
| "getMcpServers"
|
|
66
|
+
| "connectMcpServer"
|
|
67
|
+
| "disconnectMcpServer"
|
|
68
|
+
| "getSlashCommands"
|
|
69
|
+
| "searchFiles"
|
|
70
|
+
| "getPromptHistory"
|
|
71
|
+
| "searchPromptHistory"
|
|
72
|
+
| "updateConfig"
|
|
73
|
+
// Auth
|
|
74
|
+
| "getAuthStatus"
|
|
75
|
+
| "login"
|
|
76
|
+
| "logout"
|
|
77
|
+
// Plugins
|
|
78
|
+
| "listPlugins"
|
|
79
|
+
| "installPlugin"
|
|
80
|
+
| "uninstallPlugin"
|
|
81
|
+
| "enablePlugin"
|
|
82
|
+
| "disablePlugin"
|
|
83
|
+
| "updatePlugin"
|
|
84
|
+
| "listMarketplaces"
|
|
85
|
+
| "addMarketplace"
|
|
86
|
+
| "removeMarketplace"
|
|
87
|
+
| "updateMarketplace";
|
|
88
|
+
|
|
89
|
+
// ── Client → Server notification methods ────────────────────────
|
|
90
|
+
|
|
91
|
+
export type ClientNotificationMethod = "permissionResponse";
|
|
92
|
+
|
|
93
|
+
// ── Server → Client notification methods ────────────────────────
|
|
94
|
+
|
|
95
|
+
export type ServerNotificationMethod =
|
|
96
|
+
| "messagesChange"
|
|
97
|
+
| "userMessageAdded"
|
|
98
|
+
| "assistantMessageAdded"
|
|
99
|
+
| "assistantContentUpdated"
|
|
100
|
+
| "assistantReasoningUpdated"
|
|
101
|
+
| "toolBlockUpdated"
|
|
102
|
+
| "errorBlockAdded"
|
|
103
|
+
| "loadingChange"
|
|
104
|
+
| "commandRunningChange"
|
|
105
|
+
| "queuedMessagesChange"
|
|
106
|
+
| "tasksChange"
|
|
107
|
+
| "sessionIdChange"
|
|
108
|
+
| "permissionModeChange"
|
|
109
|
+
| "mcpServersChange"
|
|
110
|
+
| "bangMessageAdded"
|
|
111
|
+
| "bangMessageUpdated"
|
|
112
|
+
| "bangMessageCompleted"
|
|
113
|
+
| "notificationMessageAdded"
|
|
114
|
+
| "permissionRequest"
|
|
115
|
+
| "authUrl";
|
|
116
|
+
|
|
117
|
+
// ── Helper: is this a request (has id)? ─────────────────────────
|
|
118
|
+
|
|
119
|
+
export function isRequest(msg: unknown): msg is JsonRpcRequest {
|
|
120
|
+
return (
|
|
121
|
+
typeof msg === "object" &&
|
|
122
|
+
msg !== null &&
|
|
123
|
+
"method" in msg &&
|
|
124
|
+
"id" in msg &&
|
|
125
|
+
(typeof (msg as { id: unknown }).id === "number" ||
|
|
126
|
+
typeof (msg as { id: unknown }).id === "string")
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function isNotification(msg: unknown): msg is JsonRpcNotification {
|
|
131
|
+
return (
|
|
132
|
+
typeof msg === "object" && msg !== null && "method" in msg && !("id" in msg)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StdioServer — reads JSON-RPC messages from stdin, dispatches to AgentBridge,
|
|
3
|
+
* and writes responses / notifications to stdout.
|
|
4
|
+
*
|
|
5
|
+
* One JSON object per line. stderr is reserved for logger output.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import readline from "readline";
|
|
9
|
+
import type { Readable, Writable } from "stream";
|
|
10
|
+
import { AgentBridge, type AgentBridgeOptions } from "./agentBridge.js";
|
|
11
|
+
import {
|
|
12
|
+
type JsonRpcRequest,
|
|
13
|
+
type JsonRpcResponse,
|
|
14
|
+
type JsonRpcNotification,
|
|
15
|
+
PARSE_ERROR,
|
|
16
|
+
INVALID_REQUEST,
|
|
17
|
+
INTERNAL_ERROR,
|
|
18
|
+
isRequest,
|
|
19
|
+
isNotification,
|
|
20
|
+
} from "./protocol.js";
|
|
21
|
+
|
|
22
|
+
export interface StdioServerOptions {
|
|
23
|
+
input?: Readable;
|
|
24
|
+
output?: Writable;
|
|
25
|
+
bridgeOptions?: AgentBridgeOptions;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class StdioServer {
|
|
29
|
+
private rl: readline.Interface | undefined;
|
|
30
|
+
private bridge: AgentBridge;
|
|
31
|
+
private input: Readable;
|
|
32
|
+
private output: Writable;
|
|
33
|
+
private started = false;
|
|
34
|
+
|
|
35
|
+
constructor(options: StdioServerOptions = {}) {
|
|
36
|
+
this.input = options.input ?? process.stdin;
|
|
37
|
+
this.output = options.output ?? process.stdout;
|
|
38
|
+
this.bridge = new AgentBridge({
|
|
39
|
+
...options.bridgeOptions,
|
|
40
|
+
emit: (method, params, sessionId) =>
|
|
41
|
+
this.sendNotification(method, params, sessionId),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get agentBridge(): AgentBridge {
|
|
46
|
+
return this.bridge;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
start(): void {
|
|
50
|
+
if (this.started) return;
|
|
51
|
+
this.started = true;
|
|
52
|
+
|
|
53
|
+
this.rl = readline.createInterface({
|
|
54
|
+
input: this.input,
|
|
55
|
+
crlfDelay: Infinity,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
this.rl.on("line", (line: string) => {
|
|
59
|
+
this.handleLine(line).catch((err) => {
|
|
60
|
+
// Should never reach here — handleLine catches internally
|
|
61
|
+
this.sendResponse(null, undefined, {
|
|
62
|
+
code: INTERNAL_ERROR,
|
|
63
|
+
message: `Unhandled error: ${(err as Error).message}`,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.rl.on("close", () => {
|
|
69
|
+
this.started = false;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
stop(): void {
|
|
74
|
+
this.rl?.close();
|
|
75
|
+
this.rl = undefined;
|
|
76
|
+
this.started = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async handleLine(line: string): Promise<void> {
|
|
80
|
+
const trimmed = line.trim();
|
|
81
|
+
if (!trimmed) return;
|
|
82
|
+
|
|
83
|
+
let msg: unknown;
|
|
84
|
+
try {
|
|
85
|
+
msg = JSON.parse(trimmed);
|
|
86
|
+
} catch {
|
|
87
|
+
this.sendResponse(null, undefined, {
|
|
88
|
+
code: PARSE_ERROR,
|
|
89
|
+
message: "Parse error: invalid JSON",
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isRequest(msg)) {
|
|
95
|
+
await this.handleRequest(msg);
|
|
96
|
+
} else if (isNotification(msg)) {
|
|
97
|
+
this.handleNotification(msg);
|
|
98
|
+
} else {
|
|
99
|
+
// Echo back the id if the message has one, otherwise null
|
|
100
|
+
const id =
|
|
101
|
+
typeof msg === "object" &&
|
|
102
|
+
msg !== null &&
|
|
103
|
+
"id" in msg &&
|
|
104
|
+
(typeof (msg as { id: unknown }).id === "number" ||
|
|
105
|
+
typeof (msg as { id: unknown }).id === "string")
|
|
106
|
+
? (msg as { id: number | string }).id
|
|
107
|
+
: null;
|
|
108
|
+
this.sendResponse(id, undefined, {
|
|
109
|
+
code: INVALID_REQUEST,
|
|
110
|
+
message: "Invalid request: must have 'method' field",
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private async handleRequest(msg: JsonRpcRequest): Promise<void> {
|
|
116
|
+
try {
|
|
117
|
+
const result = await this.bridge.handleRequest(
|
|
118
|
+
msg.method,
|
|
119
|
+
msg.params,
|
|
120
|
+
msg.sessionId,
|
|
121
|
+
);
|
|
122
|
+
this.sendResponse(msg.id, result);
|
|
123
|
+
} catch (err) {
|
|
124
|
+
const code =
|
|
125
|
+
err && typeof err === "object" && "code" in err
|
|
126
|
+
? (err as { code: number }).code
|
|
127
|
+
: INTERNAL_ERROR;
|
|
128
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
129
|
+
this.sendResponse(msg.id, undefined, { code, message });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private handleNotification(msg: JsonRpcNotification): void {
|
|
134
|
+
try {
|
|
135
|
+
this.bridge.handleNotification(msg.method, msg.params);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
// Notifications don't get responses, but we log to stderr
|
|
138
|
+
process.stderr.write(
|
|
139
|
+
`Error handling notification ${msg.method}: ${(err as Error).message}\n`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Output helpers ────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
sendResponse(
|
|
147
|
+
id: number | string | null,
|
|
148
|
+
result?: unknown,
|
|
149
|
+
error?: { code: number; message: string },
|
|
150
|
+
): void {
|
|
151
|
+
const response: JsonRpcResponse = { id };
|
|
152
|
+
if (error) {
|
|
153
|
+
response.error = error;
|
|
154
|
+
} else {
|
|
155
|
+
response.result = result ?? null;
|
|
156
|
+
}
|
|
157
|
+
this.write(response);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
sendNotification(method: string, params?: unknown, sessionId?: string): void {
|
|
161
|
+
const notification: JsonRpcNotification = { method, params };
|
|
162
|
+
if (sessionId) notification.sessionId = sessionId;
|
|
163
|
+
this.write(notification);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private write(obj: JsonRpcResponse | JsonRpcNotification): void {
|
|
167
|
+
this.output.write(JSON.stringify(obj) + "\n");
|
|
168
|
+
}
|
|
169
|
+
}
|
package/src/stdio-cli.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stdio-cli.ts — Entry point for `wave --stdio` mode.
|
|
3
|
+
*
|
|
4
|
+
* Starts a StdioServer that reads JSON-RPC messages from stdin and writes
|
|
5
|
+
* responses/notifications to stdout. The server creates an Agent lazily when
|
|
6
|
+
* the client sends an "initialize" request.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { StdioServer } from "./stdio/stdioServer.js";
|
|
10
|
+
|
|
11
|
+
export async function startStdioCli(): Promise<void> {
|
|
12
|
+
const server = new StdioServer();
|
|
13
|
+
server.start();
|
|
14
|
+
|
|
15
|
+
// Keep the process alive — readline on stdin handles the event loop.
|
|
16
|
+
// When stdin closes (EOF), the readline interface emits 'close' and
|
|
17
|
+
// the process will exit naturally.
|
|
18
|
+
}
|
package/dist/acp/agent.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type Agent as AcpAgent, type AgentSideConnection, type InitializeResponse, type NewSessionRequest, type NewSessionResponse, type LoadSessionRequest, type LoadSessionResponse, type ListSessionsRequest, type ListSessionsResponse, type PromptRequest, type PromptResponse, type CancelNotification, type AuthenticateResponse, type SetSessionModeRequest, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse } from "@agentclientprotocol/sdk";
|
|
2
|
-
export declare class WaveAcpAgent implements AcpAgent {
|
|
3
|
-
private agents;
|
|
4
|
-
private connection;
|
|
5
|
-
private taskCache;
|
|
6
|
-
constructor(connection: AgentSideConnection);
|
|
7
|
-
private getSessionModeState;
|
|
8
|
-
private getSessionConfigOptions;
|
|
9
|
-
private cleanupAllAgents;
|
|
10
|
-
initialize(): Promise<InitializeResponse>;
|
|
11
|
-
authenticate(): Promise<AuthenticateResponse | void>;
|
|
12
|
-
private createAgent;
|
|
13
|
-
newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
|
|
14
|
-
loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse>;
|
|
15
|
-
listSessions(params: ListSessionsRequest): Promise<ListSessionsResponse>;
|
|
16
|
-
unstable_closeSession(params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
17
|
-
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
18
|
-
setSessionMode(params: SetSessionModeRequest): Promise<void>;
|
|
19
|
-
setSessionConfigOption(params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
|
|
20
|
-
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
21
|
-
cancel(params: CancelNotification): Promise<void>;
|
|
22
|
-
private getAllowAlwaysName;
|
|
23
|
-
private handleAskQuestion;
|
|
24
|
-
private handleCreatePlan;
|
|
25
|
-
private handlePermissionRequest;
|
|
26
|
-
private getToolContent;
|
|
27
|
-
private getToolLocations;
|
|
28
|
-
private getToolKind;
|
|
29
|
-
private replayConversationHistory;
|
|
30
|
-
private createCallbacks;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=agent.d.ts.map
|
package/dist/acp/agent.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/acp/agent.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,KAAK,KAAK,IAAI,QAAQ,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAUzB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EAQpC,MAAM,0BAA0B,CAAC;AAwBlC,qBAAa,YAAa,YAAW,QAAQ;IAC3C,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,SAAS,CAA6B;gBAElC,UAAU,EAAE,mBAAmB;IAI3C,OAAO,CAAC,mBAAmB;IAkC3B,OAAO,CAAC,uBAAuB;YAmCjB,gBAAgB;IASxB,UAAU,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAyBzC,YAAY,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;YAI5C,WAAW;IAkFnB,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAalE,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAcrE,YAAY,CAChB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAuB1B,qBAAqB,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAc7B,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAO7B,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5D,sBAAsB,CAC1B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,8BAA8B,CAAC;IAuBpC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA+DtD,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IASvD,OAAO,CAAC,kBAAkB;YA2BZ,iBAAiB;YAsEjB,gBAAgB;YAyDhB,uBAAuB;IAmNrC,OAAO,CAAC,cAAc;IA6FtB,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,WAAW;YAmBL,yBAAyB;IAoIvC,OAAO,CAAC,eAAe;CAgTxB"}
|