fix: use in-process Harness API for local plugin connections

This commit is contained in:
xmanrui 2026-08-28 01:24:17 +08:00
parent f4ded46278
commit f0b6b38b45
40 changed files with 1413 additions and 603 deletions

View file

@ -17,17 +17,9 @@ import {
import { listAgentPresetCatalog } from '../../../../src/channels/shared/agent-preset.mjs';
import { createConnectionSupervisor } from './connection-supervisor.mjs';
import { createHarnessCommandExecutor } from '../../harness-command-executor.mjs';
import { harnessConnection } from '../../harness-connection.mjs';
import { createHarnessSessionExecutors } from '../../harness-session-coordinator.mjs';
function harnessOrigin(webServer, configured) {
if (configured !== undefined) return new URL(configured);
const port = webServer?.port;
if (!Number.isInteger(port) || port < 1 || port > 65_535) {
throw new Error('dsh-im QQ requires an initialized DSH webServer port');
}
return new URL(`http://127.0.0.1:${port}`);
}
function pluginPaths(config) {
const dshHome = resolve(config.dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'));
const root = resolve(config.dataDir ?? join(dshHome, 'integrations', 'dsh-qq'));
@ -40,7 +32,7 @@ function pluginPaths(config) {
export async function createProductionController(ctx, config = {}, internals = {}) {
if (!ctx?.credentials) throw new TypeError('dsh-im QQ requires ctx.credentials');
if (!ctx?.webServer) throw new TypeError('dsh-im QQ requires ctx.webServer');
const connection = harnessConnection(ctx, config);
const ConfigStore = internals.ConfigStore ?? QqConfigStore;
const StateStore = internals.StateStore ?? QqStateStore;
@ -83,7 +75,7 @@ export async function createProductionController(ctx, config = {}, internals = {
fileIngressExecutor: internals.fileIngressExecutor,
});
const harness = new Harness({
baseUrl: harnessOrigin(ctx.webServer, config.harnessBaseUrl),
...connection,
workspace: defaultWorkspace,
autostart: false,
dshBin: config.dshBin ?? 'dsh',