mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 05:20:46 +08:00
feat: add agent preset chat commands
This commit is contained in:
parent
2ad6f1a44e
commit
eea29fe296
33 changed files with 1519 additions and 234 deletions
|
|
@ -53,6 +53,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger('dsh-dingtalk')
|
||||
: (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config);
|
||||
const configStore = await new ConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -106,7 +107,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, clientSecret }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
config: botConfig,
|
||||
clientSecret,
|
||||
|
|
@ -140,7 +143,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
controller,
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger('dsh-feishu')
|
||||
: (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config);
|
||||
const configStore = await new ConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -136,7 +137,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const state = await stateFor(botConfig);
|
||||
const id = botId ?? botConfig.id ?? botConfig.appId;
|
||||
await workspaces.ensure(id, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId: id, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId: id, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
lark,
|
||||
botId: id,
|
||||
|
|
@ -170,7 +173,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor: stateForBotId,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
|
||||
const supervisor = createSupervisor({
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const QrAuth = internals.QrAuth ?? QqQrAuth;
|
||||
const createSupervisor = internals.createConnectionSupervisor ?? createConnectionSupervisor;
|
||||
const logger = typeof ctx.logger === 'function' ? ctx.logger('dsh-im:qq') : (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config);
|
||||
const configStore = await new ConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -97,7 +98,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, appSecret }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
config: botConfig,
|
||||
appSecret,
|
||||
|
|
@ -130,7 +133,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
controller,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|||
const createSupervisor = internals.createConnectionSupervisor ?? createTokenConnectionSupervisor;
|
||||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger(`dsh-im:${channel}`) : (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config, channel);
|
||||
const configStore = await new ResolvedConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -98,7 +99,9 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|||
createRuntime: async ({ botId, config: botConfig, token }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new ResolvedRuntime({
|
||||
...channelRuntimeOptions,
|
||||
config: botConfig,
|
||||
|
|
@ -132,7 +135,7 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
channel,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const createSupervisor = internals.createConnectionSupervisor ?? createTokenConnectionSupervisor;
|
||||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger('dsh-im:slack') : (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config, 'slack');
|
||||
const configStore = await new ResolvedConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -76,7 +77,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, botToken, appToken }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new ResolvedRuntime({
|
||||
config: botConfig,
|
||||
botToken,
|
||||
|
|
@ -110,7 +113,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
channel: 'slack',
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const QrAuth = internals.QrAuth ?? WecomQrAuth;
|
||||
const createSupervisor = internals.createConnectionSupervisor ?? createConnectionSupervisor;
|
||||
const logger = typeof ctx.logger === 'function' ? ctx.logger('dsh-im:wecom') : (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config);
|
||||
const configStore = await new ConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -100,7 +101,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, secret }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
config: botConfig,
|
||||
secret,
|
||||
|
|
@ -134,7 +137,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
controller,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger('dsh-weixin')
|
||||
: (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const paths = pluginPaths(config);
|
||||
const configStore = await new ConfigStore(paths.config).load();
|
||||
const defaultWorkspace = resolve(config.workspace ?? process.cwd());
|
||||
|
|
@ -100,7 +101,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: accountConfig, token }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
api,
|
||||
config: accountConfig,
|
||||
|
|
@ -134,7 +137,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
controller,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
if (!ctx?.webServer) throw new TypeError('dsh-im WhatsApp requires ctx.webServer');
|
||||
const logger = typeof ctx.logger === 'function'
|
||||
? ctx.logger('dsh-im:whatsapp') : (ctx.logger ?? console);
|
||||
const agentPresetCatalog = () => listAgentPresetCatalog(ctx);
|
||||
const ConfigStore = internals.ConfigStore ?? WhatsappConfigStore;
|
||||
const StateStore = internals.StateStore ?? WhatsappStateStore;
|
||||
const Harness = internals.HarnessClient ?? WhatsappHarnessClient;
|
||||
|
|
@ -103,7 +104,9 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
createRuntime: async ({ botId, config: botConfig, authDir }) => {
|
||||
const state = await stateFor(botId);
|
||||
await workspaces.ensure(botId, { defaultAgentPreset: config.agentPreset });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, { botId, workspaces, state });
|
||||
const workspaceScope = createBotWorkspaceScope(harness, {
|
||||
botId, workspaces, state, agentPresetCatalog,
|
||||
});
|
||||
return new Runtime({
|
||||
config: botConfig,
|
||||
authDir,
|
||||
|
|
@ -141,7 +144,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const controller = createWorkspaceAwareController(coreController, {
|
||||
workspaces,
|
||||
stateFor,
|
||||
agentPresetCatalog: () => listAgentPresetCatalog(ctx),
|
||||
agentPresetCatalog,
|
||||
});
|
||||
const supervisor = createSupervisor({
|
||||
channel: 'whatsapp',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue