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

@ -2,7 +2,7 @@ import { createProductionController } from './production.mjs';
import { installWeixinRpc } from './rpc.mjs';
export const name = 'dsh-weixin-host';
export const inject = ['connection', 'credentials', 'webServer', 'typertGateway'];
export const inject = ['connection', 'credentials', 'apiProxy', 'typertGateway'];
export async function apply(ctx, config = {}) {
if (config?.controller) {

View file

@ -20,17 +20,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-weixin 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-weixin'));
@ -44,7 +36,7 @@ function pluginPaths(config) {
export async function createProductionController(ctx, config = {}, internals = {}) {
if (!ctx?.credentials) throw new TypeError('dsh-weixin requires ctx.credentials');
if (!ctx?.webServer) throw new TypeError('dsh-weixin requires ctx.webServer');
const connection = harnessConnection(ctx, config);
const ConfigStore = internals.ConfigStore ?? WeixinConfigStore;
const StateStore = internals.StateStore ?? WeixinStateStore;
@ -89,7 +81,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',