mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-14 23:40:49 +08:00
fix: use in-process Harness API for local plugin connections
This commit is contained in:
parent
f4ded46278
commit
f0b6b38b45
40 changed files with 1413 additions and 603 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue