mirror of
https://github.com/penpot/penpot-mcp.git
synced 2026-07-23 06:28:28 +00:00
Improve return type definition of ExecuteCodePluginTask
This commit is contained in:
parent
77f4a978be
commit
223d6d50b0
@ -78,3 +78,18 @@ export interface ExecuteCodeTaskParams {
|
||||
*/
|
||||
code: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Result data for the executeCode task.
|
||||
*/
|
||||
export interface ExecuteCodeTaskResultData<T> {
|
||||
/**
|
||||
* The result of the executed code, if any.
|
||||
*/
|
||||
result: T;
|
||||
|
||||
/**
|
||||
* Captured console output during code execution.
|
||||
*/
|
||||
log: string;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { PluginTask } from "../PluginTask";
|
||||
import { ExecuteCodeTaskParams, PluginTaskResult } from "@penpot-mcp/common";
|
||||
import { ExecuteCodeTaskParams, ExecuteCodeTaskResultData, PluginTaskResult } from "@penpot-mcp/common";
|
||||
|
||||
/**
|
||||
* Task for executing JavaScript code in the plugin context.
|
||||
@ -7,7 +7,10 @@ import { ExecuteCodeTaskParams, PluginTaskResult } from "@penpot-mcp/common";
|
||||
* This task instructs the plugin to execute arbitrary JavaScript code
|
||||
* and return the result of execution.
|
||||
*/
|
||||
export class ExecuteCodePluginTask extends PluginTask<ExecuteCodeTaskParams, PluginTaskResult<any>> {
|
||||
export class ExecuteCodePluginTask extends PluginTask<
|
||||
ExecuteCodeTaskParams,
|
||||
PluginTaskResult<ExecuteCodeTaskResultData<any>>
|
||||
> {
|
||||
/**
|
||||
* Creates a new execute code task.
|
||||
*
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Task, TaskHandler } from "../TaskHandler";
|
||||
import { ExecuteCodeTaskParams } from "../../../common/src";
|
||||
import { ExecuteCodeTaskParams, ExecuteCodeTaskResultData } from "../../../common/src";
|
||||
|
||||
/**
|
||||
* Console implementation that captures all log output for code execution.
|
||||
@ -205,10 +205,11 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
||||
|
||||
console.log("Code execution result:", result);
|
||||
|
||||
// return both result and captured log
|
||||
task.sendSuccess({
|
||||
// return result and captured log
|
||||
let resultData: ExecuteCodeTaskResultData<any> = {
|
||||
result: result,
|
||||
log: this.context.console.getLog(),
|
||||
});
|
||||
};
|
||||
task.sendSuccess(resultData);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user