|
|
@@ -1,6 +1,7 @@
|
|
|
import { type ChildProcessWithoutNullStreams, spawn } from 'node:child_process';
|
|
|
import { createInterface } from 'node:readline';
|
|
|
import { type ToolDefinition, tool } from '@opencode-ai/plugin';
|
|
|
+import packageJson from '../../package.json' with { type: 'json' };
|
|
|
import {
|
|
|
type AcpAgentConfig,
|
|
|
type AcpAgentsConfig,
|
|
|
@@ -33,6 +34,17 @@ type Pending = {
|
|
|
reject: (error: Error) => void;
|
|
|
};
|
|
|
|
|
|
+export function createAcpInitializeParams() {
|
|
|
+ return {
|
|
|
+ protocolVersion: 1,
|
|
|
+ clientCapabilities: {},
|
|
|
+ clientInfo: {
|
|
|
+ name: 'oh-my-opencode-slim',
|
|
|
+ version: packageJson.version,
|
|
|
+ },
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
class AcpClient {
|
|
|
private child: ChildProcessWithoutNullStreams;
|
|
|
private next = 1;
|
|
|
@@ -86,14 +98,7 @@ class AcpClient {
|
|
|
}
|
|
|
|
|
|
async run(prompt: string): Promise<string> {
|
|
|
- const init = await this.request('initialize', {
|
|
|
- protocolVersion: 1,
|
|
|
- clientCapabilities: {},
|
|
|
- clientInfo: {
|
|
|
- name: 'oh-my-opencode-slim',
|
|
|
- title: 'oh-my-opencode-slim ACP bridge',
|
|
|
- },
|
|
|
- });
|
|
|
+ const init = await this.request('initialize', createAcpInitializeParams());
|
|
|
this.authMethods = readAuthMethods(init);
|
|
|
const created = await this.newSession();
|
|
|
const sessionId = readSessionId(created);
|