Get workflows info via client
This commit is contained in:
parent
8becdb00aa
commit
6eb7f1f408
@ -1,24 +1,51 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from "vscode";
|
||||||
import { MessageHandler } from './messageHandler';
|
import { MessageHandler } from "./messageHandler";
|
||||||
import { regInMessage, regOutMessage } from '../util/reg_messages';
|
import { regInMessage, regOutMessage } from "../util/reg_messages";
|
||||||
import { ApiKeyManager } from '../util/apiKey';
|
import { DevChatClient } from "../toolwrapper/devchatClient";
|
||||||
import DevChat from '../toolwrapper/devchat';
|
import { logger } from "../util/logger";
|
||||||
|
|
||||||
|
let existPannel: vscode.WebviewPanel | vscode.WebviewView | undefined =
|
||||||
|
undefined;
|
||||||
|
|
||||||
let existPannel: vscode.WebviewPanel|vscode.WebviewView|undefined = undefined;
|
regInMessage({ command: "regCommandList" });
|
||||||
|
regOutMessage({
|
||||||
|
command: "regCommandList",
|
||||||
|
result: [{ name: "", pattern: "", description: "" }],
|
||||||
|
});
|
||||||
|
export async function getWorkflowCommandList(
|
||||||
|
message: any,
|
||||||
|
panel: vscode.WebviewPanel | vscode.WebviewView
|
||||||
|
): Promise<void> {
|
||||||
|
existPannel = panel;
|
||||||
|
const dcClient = new DevChatClient();
|
||||||
|
|
||||||
regInMessage({command: 'regCommandList'});
|
// All workflows registered in DevChat
|
||||||
regOutMessage({command: 'regCommandList', result: [{name: '', pattern: '', description: ''}]});
|
const workflows = await dcClient.getWorkflowList();
|
||||||
export async function getWorkflowCommandList(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
|
logger.channel()?.debug(`\n\n----- workflows: ${JSON.stringify(workflows)}`);
|
||||||
existPannel = panel;
|
|
||||||
|
|
||||||
const commandList = await new DevChat().commands();
|
// Get recommends from config
|
||||||
MessageHandler.sendMessage(panel, { command: 'regCommandList', result: commandList });
|
const workflowsConfig = await dcClient.getWorkflowConfig();
|
||||||
return;
|
const recommends = workflowsConfig.recommend?.workflows || [];
|
||||||
|
logger.channel()?.debug(`\n\n----- recommends: ${JSON.stringify(recommends)}`);
|
||||||
|
|
||||||
|
// Filter active workflows and add recommend info
|
||||||
|
const commandList = workflows
|
||||||
|
.filter((workflow) => workflow.active)
|
||||||
|
.map((workflow: any) => ({
|
||||||
|
...workflow,
|
||||||
|
recommend: recommends.indexOf(workflow.name),
|
||||||
|
}));
|
||||||
|
|
||||||
|
MessageHandler.sendMessage(panel, {
|
||||||
|
command: "regCommandList",
|
||||||
|
result: commandList,
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendCommandListByDevChatRun() {
|
export async function sendCommandListByDevChatRun() {
|
||||||
if (existPannel) {
|
if (existPannel) {
|
||||||
await getWorkflowCommandList({}, existPannel!);
|
await getWorkflowCommandList({}, existPannel!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,31 @@ export class DevChatClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@timeThis
|
||||||
|
async getWorkflowList(): Promise<any> {
|
||||||
|
const response = await this._get("/workflow/list");
|
||||||
|
logger
|
||||||
|
.channel()
|
||||||
|
?.debug(
|
||||||
|
`getWorkflowList response data: \n${JSON.stringify(
|
||||||
|
response.data
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@timeThis
|
||||||
|
async getWorkflowConfig(): Promise<any> {
|
||||||
|
const response = await this._get("/workflow/config");
|
||||||
|
logger
|
||||||
|
.channel()
|
||||||
|
?.debug(
|
||||||
|
`getWorkflowConfig response data: \n${JSON.stringify(
|
||||||
|
response.data
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
@timeThis
|
@timeThis
|
||||||
async updateWorkflows(): Promise<void> {
|
async updateWorkflows(): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user