mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 07:53:20 +08:00
fix: complete per-bot agent preset lifecycle
This commit is contained in:
parent
8ab4b9e7de
commit
01576f65c6
27 changed files with 721 additions and 208 deletions
|
|
@ -129,7 +129,7 @@ export class ConnectionSupervisor {
|
|||
await this.#controller.initialize();
|
||||
if (this.#closed) return;
|
||||
|
||||
const status = this.#controller.status();
|
||||
const status = await this.#controller.status();
|
||||
this.#resolveReady?.(status);
|
||||
this.#resolveReady = null;
|
||||
const current = totals(status);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
if (canListConfiguredBots) {
|
||||
await workspaces.reconcile(configuredBots.map((bot) => bot.id));
|
||||
}
|
||||
await Promise.all(configuredBots.map((bot) => workspaces.ensure(bot.id)));
|
||||
await Promise.all(configuredBots.map((bot) => workspaces.ensure(bot.id, {
|
||||
defaultAgentPreset: config.agentPreset,
|
||||
})));
|
||||
const observedConfigStore = typeof configStore.removeBot === 'function'
|
||||
? observeBotWorkspaceRemovals(configStore, {
|
||||
workspaces,
|
||||
|
|
@ -116,7 +118,6 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const harness = new Harness({
|
||||
baseUrl: harnessOrigin(ctx.webServer, config.harnessBaseUrl),
|
||||
workspace: defaultWorkspace,
|
||||
...(config.agentPreset == null ? {} : { agentPreset: config.agentPreset }),
|
||||
// This plugin is already hosted by a running DSH process. Starting a
|
||||
// second DSH would create a competing server and lifecycle.
|
||||
autostart: false,
|
||||
|
|
@ -134,7 +135,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, appSecret, repair }) => {
|
||||
const state = await stateFor(botConfig);
|
||||
const id = botId ?? botConfig.id ?? botConfig.appId;
|
||||
await workspaces.ensure(id);
|
||||
await workspaces.ensure(id, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId: id, workspaces, state });
|
||||
return new Runtime({
|
||||
lark,
|
||||
|
|
@ -167,7 +168,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor: stateForBotId,
|
||||
agentPresetCatalog: await listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
});
|
||||
|
||||
const supervisor = createSupervisor({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import QRCode from 'qrcode';
|
||||
import {
|
||||
normalizeAgentPresetCatalog,
|
||||
normalizeAgentPresetId,
|
||||
} from '../../../../src/channels/shared/agent-preset.mjs';
|
||||
import { publicConnectionTestResult } from '../../../../src/channels/shared/connection-test.mjs';
|
||||
import { resolveRpcAuthority } from '../../rpc-authority.mjs';
|
||||
import { publicWorkspaceError, validWorkspacePayload } from '../shared/workspace-rpc.mjs';
|
||||
|
|
@ -254,6 +258,7 @@ function publicBotEntry(entry) {
|
|||
state: connectionState(source, registration, connected),
|
||||
connected,
|
||||
configured: source.configured === true,
|
||||
agentPreset: normalizeAgentPresetId(source.agentPreset),
|
||||
bot: publicBot(source.bot),
|
||||
health: publicHealth(source, connected),
|
||||
};
|
||||
|
|
@ -295,6 +300,7 @@ export async function toPublicFeishuStatus(status, { encodeQr = qrCodeDataUrl }
|
|||
bot: publicBot(source.bot),
|
||||
health: publicHealth(source, connected),
|
||||
bots,
|
||||
agentPresetCatalog: normalizeAgentPresetCatalog(source.agentPresetCatalog),
|
||||
totals: {
|
||||
configured: bots.length || (source.configured === true ? 1 : 0),
|
||||
connected: bots.length ? bots.filter((bot) => bot.connected).length : (connected ? 1 : 0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue