mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-16 04:50:29 -07:00
feat(workspaces): implement Workspaces UI and action primitives
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
|
||||
import type { Content, PartListUnion } from '@google/genai';
|
||||
import type { WorkspaceHubInfo } from '../services/workspaceHubClient.js';
|
||||
|
||||
/**
|
||||
* The return type for a command action that results in scheduling a tool call.
|
||||
*/
|
||||
@@ -19,6 +21,11 @@ export interface ToolActionReturn {
|
||||
postSubmitPrompt?: PartListUnion;
|
||||
}
|
||||
|
||||
export interface WorkspacesListActionReturn {
|
||||
type: 'workspaces_list';
|
||||
workspaces: WorkspaceHubInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The return type for a command action that results in a simple message
|
||||
* being displayed to the user.
|
||||
@@ -50,6 +57,7 @@ export interface SubmitPromptActionReturn {
|
||||
|
||||
export type CommandActionReturn<HistoryType = unknown> =
|
||||
| ToolActionReturn
|
||||
| WorkspacesListActionReturn
|
||||
| MessageActionReturn
|
||||
| LoadHistoryActionReturn<HistoryType>
|
||||
| SubmitPromptActionReturn;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { Config } from '../config/config.js';
|
||||
import { WorkspaceHubClient } from '../services/workspaceHubClient.js';
|
||||
import type { MessageActionReturn } from './types.js';
|
||||
import type { CommandActionReturn } from './types.js';
|
||||
|
||||
function getHubUrl(config: Config): string {
|
||||
if (process.env['GEMINI_WORKSPACE_HUB_URL']) {
|
||||
@@ -26,7 +26,7 @@ function getHubUrl(config: Config): string {
|
||||
|
||||
export async function listWorkspaces(
|
||||
config: Config,
|
||||
): Promise<MessageActionReturn> {
|
||||
): Promise<CommandActionReturn> {
|
||||
const hubUrl = getHubUrl(config);
|
||||
const client = new WorkspaceHubClient(hubUrl);
|
||||
|
||||
@@ -41,17 +41,9 @@ export async function listWorkspaces(
|
||||
};
|
||||
}
|
||||
|
||||
let content = 'Active Workspaces:\n';
|
||||
content += '------------------------------------------------------------\n';
|
||||
for (const ws of workspaces) {
|
||||
content += `${ws.name.padEnd(20)} | ${ws.status.padEnd(12)} | ${ws.id}\n`;
|
||||
}
|
||||
content += '------------------------------------------------------------';
|
||||
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'info',
|
||||
content,
|
||||
type: 'workspaces_list',
|
||||
workspaces,
|
||||
};
|
||||
} catch (error: unknown) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
@@ -68,7 +60,7 @@ export async function createWorkspace(
|
||||
config: Config,
|
||||
name: string,
|
||||
machineType?: string,
|
||||
): Promise<MessageActionReturn> {
|
||||
): Promise<CommandActionReturn> {
|
||||
const hubUrl = getHubUrl(config);
|
||||
const client = new WorkspaceHubClient(hubUrl);
|
||||
|
||||
@@ -93,7 +85,7 @@ export async function createWorkspace(
|
||||
export async function deleteWorkspace(
|
||||
config: Config,
|
||||
id: string,
|
||||
): Promise<MessageActionReturn> {
|
||||
): Promise<CommandActionReturn> {
|
||||
const hubUrl = getHubUrl(config);
|
||||
const client = new WorkspaceHubClient(hubUrl);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user