mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 22:50:47 +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
|
|
@ -3,7 +3,7 @@ import { createProductionController } from './production.mjs';
|
|||
import { installFeishuRpc } from './rpc.mjs';
|
||||
|
||||
export const name = 'dsh-feishu-host';
|
||||
export const inject = ['connection', 'credentials', 'webServer', 'typertGateway'];
|
||||
export const inject = ['connection', 'credentials', 'apiProxy', 'typertGateway'];
|
||||
|
||||
function controllerFrom(ctx, config) {
|
||||
if (config?.controller) return config.controller;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import * as Lark from '@larksuiteoapi/node-sdk';
|
|||
import HttpsProxyAgent from 'https-proxy-agent';
|
||||
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';
|
||||
import { verifyFeishuApp } from '../../../../src/channels/feishu/feishu-app.mjs';
|
||||
import { FeishuRuntime } from '../../../../src/channels/feishu/feishu-runtime.mjs';
|
||||
|
|
@ -39,17 +40,6 @@ export function createFeishuWebSocketAgent(
|
|||
return proxyUrl ? createAgent(proxyUrl) : undefined;
|
||||
}
|
||||
|
||||
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-feishu requires an initialized DSH webServer port');
|
||||
}
|
||||
// Even when DSH listens on all interfaces, its own plugin talks through the
|
||||
// loopback authority accepted by Connection's request-trust fence.
|
||||
return new URL(`http://127.0.0.1:${port}`);
|
||||
}
|
||||
|
||||
function pluginPaths(config) {
|
||||
const dshHome = resolve(config.dshHome
|
||||
?? process.env.DSH_HOME
|
||||
|
|
@ -70,7 +60,7 @@ function pluginPaths(config) {
|
|||
*/
|
||||
export async function createProductionController(ctx, config = {}, internals = {}) {
|
||||
if (!ctx?.credentials) throw new TypeError('dsh-feishu requires ctx.credentials');
|
||||
if (!ctx?.webServer) throw new TypeError('dsh-feishu requires ctx.webServer');
|
||||
const connection = harnessConnection(ctx, config);
|
||||
|
||||
const lark = internals.lark ?? Lark;
|
||||
const Controller = internals.Controller ?? MultiBotDshFeishuController;
|
||||
|
|
@ -139,7 +129,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
fileIngressExecutor: internals.fileIngressExecutor,
|
||||
});
|
||||
const harness = new Harness({
|
||||
baseUrl: harnessOrigin(ctx.webServer, config.harnessBaseUrl),
|
||||
...connection,
|
||||
workspace: defaultWorkspace,
|
||||
// This plugin is already hosted by a running DSH process. Starting a
|
||||
// second DSH would create a competing server and lifecycle.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue