Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions workspaces/mi/mi-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export * from "./rpc-types/mi-data-mapper/index";
export * from "./rpc-types/mi-data-mapper/rpc-type";
export * from "./rpc-types/mi-data-mapper/types";

export * from "./rpc-types/ai-panel/index";
export * from "./rpc-types/ai-panel/rpc-type";
export * from "./rpc-types/ai-panel/types";
export * from "./rpc-types/ai-features/index";
export * from "./rpc-types/ai-features/rpc-type";
export * from "./rpc-types/ai-features/types";

export * from "./rpc-types/agent-mode/index";
export * from "./rpc-types/agent-mode/rpc-type";
export * from "./rpc-types/agent-mode/types";
33 changes: 33 additions & 0 deletions workspaces/mi/mi-core/src/rpc-types/agent-mode/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com/) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// Export types
export type {
SendAgentMessageRequest,
SendAgentMessageResponse,
AgentEvent,
AgentEventType,
MIAgentPanelAPI
} from './types';

// Export RPC type definitions
export {
sendAgentMessage,
abortAgentGeneration,
agentEvent
} from './rpc-type';
41 changes: 41 additions & 0 deletions workspaces/mi/mi-core/src/rpc-types/agent-mode/rpc-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com/) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { RequestType, NotificationType } from "vscode-messenger-common";
import {
SendAgentMessageRequest,
SendAgentMessageResponse,
AgentEvent
} from "./types";

const _prefix = "mi-agent-service";

// Send a message to the agent
export const sendAgentMessage: RequestType<SendAgentMessageRequest, SendAgentMessageResponse> = {
method: `${_prefix}/sendAgentMessage`
};

// Abort agent generation
export const abortAgentGeneration: RequestType<void, void> = {
method: `${_prefix}/abortAgentGeneration`
};

// Notification for agent streaming events
export const agentEvent: NotificationType<AgentEvent> = {
method: `${_prefix}/agentEvent`
};
70 changes: 70 additions & 0 deletions workspaces/mi/mi-core/src/rpc-types/agent-mode/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com/) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// ============================================================================
// Agent Panel Types
// ============================================================================

/**
* Request to send a message to the agent
*/
export interface SendAgentMessageRequest {
message: string;
}

/**
* Response from the agent
*/
export interface SendAgentMessageResponse {
success: boolean;
message?: string;
modifiedFiles?: string[];
error?: string;
}

/**
* Agent event types for streaming
*/
export type AgentEventType =
| "start"
| "content_block"
| "tool_call"
| "tool_result"
| "error"
| "abort"
| "stop";

/**
* Agent event for streaming
*/
export interface AgentEvent {
type: AgentEventType;
content?: string;
toolName?: string;
toolInput?: unknown;
toolOutput?: unknown;
error?: string;
}

/**
* Agent Panel API interface
*/
export interface MIAgentPanelAPI {
sendAgentMessage: (request: SendAgentMessageRequest) => Promise<SendAgentMessageResponse>;
abortAgentGeneration: () => Promise<void>;
}
8 changes: 5 additions & 3 deletions workspaces/mi/mi-extension/src/RPCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import { stateChanged, getVisualizerState, getAIVisualizerState, VisualizerLocat
import { registerMiDiagramRpcHandlers } from './rpc-managers/mi-diagram/rpc-handler';
import { VisualizerWebview } from './visualizer/webview';
import { registerMiVisualizerRpcHandlers } from './rpc-managers/mi-visualizer/rpc-handler';
import { AiPanelWebview } from './ai-panel/webview';
import { StateMachineAI } from './ai-panel/aiMachine';
import { AiPanelWebview } from './ai-features/webview';
import { StateMachineAI } from './ai-features/aiMachine';
import { registerMiDataMapperRpcHandlers } from './rpc-managers/mi-data-mapper/rpc-handler';
import { extension } from './MIExtensionContext';
import { registerMiDebuggerRpcHandlers } from './rpc-managers/mi-debugger/rpc-handler';
import { registerMIAiPanelRpcHandlers } from './rpc-managers/ai-panel/rpc-handler';
import { registerMIAiPanelRpcHandlers } from './rpc-managers/ai-features/rpc-handler';
import { registerMIAgentPanelRpcHandlers } from './rpc-managers/agent-mode/rpc-handler';
import path = require('path');
import { getStateMachine } from './stateMachine';
import { getPopupStateMachine } from './stateMachinePopup';
Expand All @@ -53,6 +54,7 @@ export class RPCLayer {
registerMiDataMapperRpcHandlers(messenger, projectUri);
registerMiDebuggerRpcHandlers(messenger, projectUri);
registerMIAiPanelRpcHandlers(messenger, projectUri);
registerMIAgentPanelRpcHandlers(messenger, projectUri);
// ----- AI Webview RPC Methods
messenger.onRequest(getAIVisualizerState, () => getAIContext());
messenger.onRequest(sendAIStateEvent, (event: any) => StateMachineAI.sendEvent(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { extension } from '../MIExtensionContext';
import { PromptObject } from '@wso2/mi-core';

export function activateAiPanel(context: vscode.ExtensionContext) {
// Register the AI panel command
context.subscriptions.push(
vscode.commands.registerCommand(COMMANDS.OPEN_AI_PANEL, (initialPrompt?: PromptObject) => {
openAIWebview(initialPrompt);
extension.initialPrompt = initialPrompt;
openAIWebview();
})
);
context.subscriptions.push(
Expand Down
Loading
Loading