Skip to content

feat: agent workspaces manager#1067

Open
MarsKubeX wants to merge 5 commits intokortex-hub:mainfrom
MarsKubeX:feat/agent-workspaces-manager
Open

feat: agent workspaces manager#1067
MarsKubeX wants to merge 5 commits intokortex-hub:mainfrom
MarsKubeX:feat/agent-workspaces-manager

Conversation

@MarsKubeX
Copy link
Contributor

@MarsKubeX MarsKubeX commented Mar 5, 2026

Add a mock backend component to manage agent workspaces in memory, as a foundation for the Agentic Coding Workspaces feature.

The services added to the backend are:

  • List — Returns all agent workspaces currently in memory
  • Get — Returns a single workspace by its ID; throws if not found
  • GetStatus — Returns live status (state + context usage) for a workspace
  • Create — Creates a new workspace from the given options
  • Start — Transitions a workspace to running status and records startedAt.
  • Stop — Transitions a workspace to stopped status.
  • Delete — Permanently removes a workspace from memory; throws if not found

All mutating operations emit an agent-workspace:updated event so the renderer can refresh the workspace list.

Added test unit for agent-workspace-manager.ts

Closes #1039

@MarsKubeX MarsKubeX requested a review from a team as a code owner March 5, 2026 13:00
@MarsKubeX MarsKubeX requested review from benoitf, bmahabirbu and gastoner and removed request for a team March 5, 2026 13:00
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

This pull request introduces an in-memory agent workspace management system. It defines TypeScript types and interfaces for workspace data structures, implements an AgentWorkspaceManager class with CRUD and lifecycle operations, integrates the manager into the dependency injection container, and exposes public IPC-based APIs for renderer process communication. Includes comprehensive test coverage for all manager functionality.

Changes

Cohort / File(s) Summary
Data Shapes
packages/api/src/agent-workspace-info.ts
New type definitions: AgentType ('claude', 'cursor', 'goose'), AgentWorkspaceStatus ('running', 'stopped', 'error'), FileAccessLevel ('workspace', 'home', 'custom', 'full'). New interfaces: AgentWorkspaceInfo with workspace metadata, context usage, resources, and stats; AgentWorkspaceCreateOptions for workspace initialization parameters.
Manager Implementation
packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts, ...agent-workspace-manager.spec.ts
AgentWorkspaceManager class providing in-memory workspace CRUD operations (list, get, create, start, stop, delete), IPC handler registration, default model selection per agent, context window calculations, lifecycle state management, and event emission. Comprehensive test suite validating initialization, CRUD operations, error handling, idempotent behavior, and event emissions.
Plugin Integration
packages/main/src/plugin/index.ts
Import and singleton registration of AgentWorkspaceManager in dependency injection container; initialization after FlowManager during plugin startup.
Preload API Exposure
packages/preload/src/index.ts
Public API methods delegating to IPC channels: listAgentWorkspaces, getAgentWorkspace, createAgentWorkspace, startAgentWorkspace, stopAgentWorkspace, deleteAgentWorkspace. New type imports (AgentWorkspaceInfo, AgentWorkspaceCreateOptions) for API signatures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: agent workspaces manager' clearly and concisely summarizes the main change in the PR—adding a new agent workspaces management backend component.
Linked Issues check ✅ Passed The PR successfully fulfills all objectives from issue #1039: adds an in-memory mock component, initializes sample workspaces, and supports workspace creation with CRUD operations and status transitions.
Out of Scope Changes check ✅ Passed All code changes are within scope and directly support the agent workspace management feature. No unrelated modifications to other systems or features were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description accurately relates to the changeset by detailing the backend services (List, Get, Create, Start, Stop, Delete) and aligning with the code changes that implement AgentWorkspaceManager with IPC operations and event emissions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts (1)

110-177: Add one malformed-input test for create() to lock runtime validation behavior.

Given IPC inputs are runtime values, include a negative test (casted invalid payload) to prevent regressions once validation is added.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts`
around lines 110 - 177, Add a negative unit test in the existing "create"
describe block that calls manager.create with a clearly malformed payload (e.g.,
{ name: 123, agent: null } cast through unknown/any) and assert the call throws
(or rejects) to lock current runtime validation behavior; reference
manager.create in the test (name it like 'rejects malformed input') and use the
same test harness expectations pattern (expect(() =>
manager.create(badPayload)).toThrow()) so the CI will catch future regressions
when runtime validation changes.
packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts (1)

182-213: Make init() idempotent to avoid duplicate IPC handler registration.

A second init() call can register handlers again. Add a lightweight init guard to keep lifecycle safe.

♻️ Proposed lifecycle guard
   init(): void {
+    if (this.#initialized) {
+      return;
+    }
+    this.#initialized = true;
+
     for (const ws of this.loadWorkspaces()) {
       this.#workspaces.set(ws.id, ws);
     }
@@
   `@preDestroy`()
   dispose(): void {
+    this.#initialized = false;
     this.#workspaces.clear();
   }

Also applies to: 215-218

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts` around
lines 182 - 213, The init() method currently registers IPC handlers every call
which can lead to duplicates; add a lightweight idempotency guard (e.g., a
private boolean like this.#inited) checked at the start of init() that returns
immediately if already true, and set the flag to true after handlers are
registered; apply the same guard pattern to the analogous initialization block
around the other IPC registrations referenced (lines 215-218) so each handler is
only registered once (reference symbols: init(), ipcHandle, and the new private
flag name such as `#inited`).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts`:
- Around line 109-126: The create() method currently trusts the runtime IPC
payload shaped as AgentWorkspaceCreateOptions; add explicit runtime validation
at the start of AgentWorkspaceManager.create() to guard against malformed inputs
(validate required fields like options.name and options.agent are present and of
correct type, whitelist fileAccess values, ensure model is valid or replace via
getDefaultModel(options.agent), validate workingDirectory is a non-empty string,
ensure skills and mcpServers are arrays and customPaths if present is an
object/array), and throw a clear error (or return a rejected result) when
validation fails before constructing the AgentWorkspaceInfo; use existing
helpers getDefaultModel() and getContextWindowSize(model) to normalize/derive
model and contextUsage after validation.

In `@packages/preload/src/index.ts`:
- Around line 409-435: The generated preload type declarations are missing the
six Agent Workspace APIs exposed via contextBridge in index.ts; update the
preload type generation so packages/preload/exposedInMainWorld.d.ts includes
type signatures for listAgentWorkspaces, getAgentWorkspace,
createAgentWorkspace, startAgentWorkspace, stopAgentWorkspace, and
deleteAgentWorkspace (matching AgentWorkspaceInfo and
AgentWorkspaceCreateOptions types). Modify the type-generation entry (the code
that emits exposedInMainWorld.d.ts) to pick up the new exports from
packages/preload/src/index.ts and then run/verify the build task (pnpm run
build:preload:types) to ensure the file is created and contains the exact method
signatures exposedInMainWorld expects.

---

Nitpick comments:
In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts`:
- Around line 110-177: Add a negative unit test in the existing "create"
describe block that calls manager.create with a clearly malformed payload (e.g.,
{ name: 123, agent: null } cast through unknown/any) and assert the call throws
(or rejects) to lock current runtime validation behavior; reference
manager.create in the test (name it like 'rejects malformed input') and use the
same test harness expectations pattern (expect(() =>
manager.create(badPayload)).toThrow()) so the CI will catch future regressions
when runtime validation changes.

In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts`:
- Around line 182-213: The init() method currently registers IPC handlers every
call which can lead to duplicates; add a lightweight idempotency guard (e.g., a
private boolean like this.#inited) checked at the start of init() that returns
immediately if already true, and set the flag to true after handlers are
registered; apply the same guard pattern to the analogous initialization block
around the other IPC registrations referenced (lines 215-218) so each handler is
only registered once (reference symbols: init(), ipcHandle, and the new private
flag name such as `#inited`).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dce63b9b-a0df-432f-afd0-177b7429a85d

📥 Commits

Reviewing files that changed from the base of the PR and between a816a4c and dd65415.

📒 Files selected for processing (5)
  • packages/api/src/agent-workspace-info.ts
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts
  • packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts
  • packages/main/src/plugin/index.ts
  • packages/preload/src/index.ts

Comment on lines +109 to +126
create(options: AgentWorkspaceCreateOptions): AgentWorkspaceInfo {
const model = options.model ?? this.getDefaultModel(options.agent);
const workspace: AgentWorkspaceInfo = {
id: randomUUID(),
name: options.name,
description: options.description ?? '',
agent: options.agent,
model,
status: 'stopped',
workingDirectory: options.workingDirectory ?? '.',
contextUsage: { used: 0, total: this.getContextWindowSize(model) },
resources: {
skills: options.skills ?? [],
mcpServers: options.mcpServers ?? [],
},
fileAccess: options.fileAccess ?? 'workspace',
customPaths: options.customPaths,
stats: { messages: 0, toolCalls: 0, filesModified: 0, linesChanged: 0 },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Validate create() IPC payloads at runtime before building workspace state.

AgentWorkspaceCreateOptions is compile-time only; malformed runtime payloads can still pass through IPC and create inconsistent objects (for example invalid agent / fileAccess combinations). Add explicit runtime guards in create().

🔒 Proposed defensive validation patch
 export class AgentWorkspaceManager implements Disposable {
   `#workspaces`: Map<string, AgentWorkspaceInfo> = new Map();
+  `#initialized` = false;
+
+  private readonly allowedAgents = new Set(['claude', 'cursor', 'goose']);
+  private readonly allowedFileAccess = new Set(['workspace', 'home', 'custom', 'full']);

@@
   create(options: AgentWorkspaceCreateOptions): AgentWorkspaceInfo {
+    if (!this.allowedAgents.has(options.agent)) {
+      throw new Error(`Unsupported agent type: ${String(options.agent)}`);
+    }
+
+    const fileAccess = options.fileAccess ?? 'workspace';
+    if (!this.allowedFileAccess.has(fileAccess)) {
+      throw new Error(`Unsupported file access level: ${String(fileAccess)}`);
+    }
+    if (fileAccess === 'custom' && (!options.customPaths || options.customPaths.length === 0)) {
+      throw new Error('customPaths is required when fileAccess is "custom"');
+    }
+
     const model = options.model ?? this.getDefaultModel(options.agent);
     const workspace: AgentWorkspaceInfo = {
@@
-      fileAccess: options.fileAccess ?? 'workspace',
-      customPaths: options.customPaths,
+      fileAccess,
+      customPaths: fileAccess === 'custom' ? options.customPaths : undefined,
       stats: { messages: 0, toolCalls: 0, filesModified: 0, linesChanged: 0 },
       createdAt: new Date().toISOString(),
     };

Also applies to: 162-170

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts` around
lines 109 - 126, The create() method currently trusts the runtime IPC payload
shaped as AgentWorkspaceCreateOptions; add explicit runtime validation at the
start of AgentWorkspaceManager.create() to guard against malformed inputs
(validate required fields like options.name and options.agent are present and of
correct type, whitelist fileAccess values, ensure model is valid or replace via
getDefaultModel(options.agent), validate workingDirectory is a non-empty string,
ensure skills and mcpServers are arrays and customPaths if present is an
object/array), and throw a clear error (or return a rejected result) when
validation fails before constructing the AgentWorkspaceInfo; use existing
helpers getDefaultModel() and getContextWindowSize(model) to normalize/derive
model and contextUsage after validation.

Comment on lines +409 to +435
// Agent Workspaces
contextBridge.exposeInMainWorld('listAgentWorkspaces', async (): Promise<AgentWorkspaceInfo[]> => {
return ipcInvoke('agent-workspace:list');
});

contextBridge.exposeInMainWorld('getAgentWorkspace', async (id: string): Promise<AgentWorkspaceInfo> => {
return ipcInvoke('agent-workspace:get', id);
});

contextBridge.exposeInMainWorld(
'createAgentWorkspace',
async (options: AgentWorkspaceCreateOptions): Promise<AgentWorkspaceInfo> => {
return ipcInvoke('agent-workspace:create', options);
},
);

contextBridge.exposeInMainWorld('startAgentWorkspace', async (id: string): Promise<AgentWorkspaceInfo> => {
return ipcInvoke('agent-workspace:start', id);
});

contextBridge.exposeInMainWorld('stopAgentWorkspace', async (id: string): Promise<AgentWorkspaceInfo> => {
return ipcInvoke('agent-workspace:stop', id);
});

contextBridge.exposeInMainWorld('deleteAgentWorkspace', async (id: string): Promise<void> => {
return ipcInvoke('agent-workspace:delete', id);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching generated preload declaration files..."
fd 'exposedInMainWorld\.d\.ts$|preload.*\.d\.ts$' packages

echo
echo "Checking for new Agent Workspace API signatures..."
fd 'exposedInMainWorld\.d\.ts$|preload.*\.d\.ts$' packages | while read -r f; do
  echo "== $f =="
  rg -n "listAgentWorkspaces|getAgentWorkspace|createAgentWorkspace|startAgentWorkspace|stopAgentWorkspace|deleteAgentWorkspace" "$f" || true
done

Repository: kortex-hub/kortex

Length of output: 161


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking packages/preload directory structure ==="
ls -la packages/preload/ 2>/dev/null | head -20

echo
echo "=== Looking for ALL .d.ts files in packages ==="
fd '\.d\.ts$' packages | head -20

echo
echo "=== Searching for 'exposedInMainWorld' anywhere in codebase ==="
rg -l "exposedInMainWorld" packages --type ts --type tsx 2>/dev/null | head -10

echo
echo "=== Checking for type definitions in packages/preload/src ==="
ls -la packages/preload/src/ 2>/dev/null

Repository: kortex-hub/kortex

Length of output: 704


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Viewing packages/preload/src/index.ts ==="
wc -l packages/preload/src/index.ts
head -50 packages/preload/src/index.ts

echo
echo "=== Checking if there's a preload.d.ts or type definition anywhere ==="
rg "exposeInMainWorld" packages --type ts -A 2 | head -40

echo
echo "=== Looking at packages/renderer for preload type imports ==="
fd . packages/renderer/src -name "*.ts" -o -name "*.tsx" | xargs rg -l "preload|exposedInMainWorld" 2>/dev/null | head -5

echo
echo "=== Checking vite config for preload ==="
cat packages/preload/vite.config.js

Repository: kortex-hub/kortex

Length of output: 4798


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Finding `@kortex-app/api` package ==="
find . -name "@kortex-app" -o -name "api" | grep -E "packages|src" | head -20

echo
echo "=== Checking packages directory structure ==="
ls -la packages/

echo
echo "=== Searching for where window types are extended for preload ==="
rg "window\." packages --type ts -B 2 -A 2 | grep -E "listAgentWorkspaces|getAgentWorkspace|createAgentWorkspace|startAgentWorkspace|stopAgentWorkspace|deleteAgentWorkspace" -B 2 -A 2 || echo "No matches found"

echo
echo "=== Looking for type definitions in api package ==="
find packages -type d -name "*api*"

Repository: kortex-hub/kortex

Length of output: 1248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking packages/api structure ==="
find packages/api -type f | head -40

echo
echo "=== Searching for agent-workspace type definitions ==="
rg "AgentWorkspace" packages/api --type ts

echo
echo "=== Checking packages/api/src/index.ts or main export ==="
ls -la packages/api/src/

echo
echo "=== Looking for any window type augmentation ==="
rg "window\[|Window {|interface.*Window|declare global" packages/api --type ts -B 1 -A 3 | head -30

Repository: kortex-hub/kortex

Length of output: 7400


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking packages/api/src/index.ts ==="
ls -la packages/api/src/index.ts 2>/dev/null || echo "No index.ts found"

echo
echo "=== Searching for window or preload interface in renderer ==="
rg "interface.*Preload\|declare.*window\|window:" packages/renderer --type ts -B 2 -A 5 | head -50

echo
echo "=== Looking for containerDesktopAPI or API type exports ==="
rg "export.*type\|export.*interface" packages/api/src/index.ts || echo "Checking if index.ts exists..."

echo
echo "=== Checking renderer/src for window augmentation ==="
find packages/renderer/src -name "*.ts" -o -name "*.tsx" | xargs rg "declare global\|window\." --max-count=5 2>/dev/null | head -40

echo
echo "=== Viewing agent-workspace-info.ts ==="
cat packages/api/src/agent-workspace-info.ts

Repository: kortex-hub/kortex

Length of output: 184


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking packages/api root files ==="
ls -la packages/api/

echo
echo "=== Viewing agent-workspace-info.ts ==="
cat packages/api/src/agent-workspace-info.ts

echo
echo "=== Searching for containerDesktopAPI type definition ==="
rg "containerDesktopAPI\|type.*API\|interface.*API" packages --type ts | grep -v node_modules | head -20

echo
echo "=== Looking in packages/extension-api for type definitions ==="
cat packages/extension-api/src/extension-api.d.ts | head -100

Repository: kortex-hub/kortex

Length of output: 2260


🏁 Script executed:

#!/bin/bash
set -euo pipefixpipe

echo "=== Viewing preload vite.config.js ==="
cat packages/preload/vite.config.js

echo
echo "=== Checking for any .d.ts generation in build config ==="
find packages -name "vite.config.js" -o -name "tsconfig.json" | xargs grep -l "dts\|declaration\|types" 2>/dev/null

echo
echo "=== Viewing packages/api vite.config.js ==="
cat packages/api/vite.config.js

echo
echo "=== Searching for window type augmentation in entire renderer package ==="
find packages/renderer/src -type f \( -name "*.ts" -o -name "*.tsx" \) | xargs grep -l "window" | head -5

echo
echo "=== Checking for types in renderer shim or env files ==="
cat packages/renderer/src/vite-env.d.ts 2>/dev/null || echo "No vite-env.d.ts"

Repository: kortex-hub/kortex

Length of output: 117


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Viewing preload vite.config.js ==="
cat packages/preload/vite.config.js

echo
echo "=== Viewing packages/api vite.config.js ==="
cat packages/api/vite.config.js

echo
echo "=== Searching for window type augmentation in renderer ==="
find packages/renderer/src -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -l "window" {} \; | head -5

echo
echo "=== Checking for types in renderer shim or env files ==="
cat packages/renderer/src/vite-env.d.ts 2>/dev/null || echo "No vite-env.d.ts"

echo
echo "=== Searching for preload API types anywhere in renderer ==="
rg "listAgentWorkspaces\|getAgentWorkspace\|createAgentWorkspace" packages/renderer --type ts

Repository: kortex-hub/kortex

Length of output: 16484


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Searching for how renderer uses window properties ==="
rg "window\." packages/renderer/src --type ts --max-count=10

echo
echo "=== Looking for renderer main entry point ==="
find packages/renderer/src -name "main.ts" -o -name "App.svelte" -o -name "index.ts" | head -3

echo
echo "=== Checking if there are any .d.ts type declaration files in renderer ==="
find packages/renderer -name "*.d.ts"

echo
echo "=== Searching for preload imports in renderer ==="
rg "from.*preload\|import.*preload" packages/renderer --type ts

echo
echo "=== Checking tsconfig.json in renderer ==="
cat packages/renderer/tsconfig.json | grep -A 10 "types\|includes" || echo "No type config found"

Repository: kortex-hub/kortex

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Looking for global type declarations ==="
find packages -name "global.d.ts" -o -name "ambient.d.ts" -o -name "window.d.ts"

echo
echo "=== Searching for window interface extensions specifically ==="
rg "interface.*Window\|declare.*Window" packages --type ts -B 1 -A 5 | head -50

echo
echo "=== Checking preload package.json for types/exports ==="
cat packages/preload/package.json 2>/dev/null || echo "No package.json"

echo
echo "=== Looking in dist directories for generated types ==="
find packages -path "*/dist/*.d.ts" | head -10

Repository: kortex-hub/kortex

Length of output: 169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking preload package.json ==="
cat packages/preload/package.json

echo
echo "=== Looking for containerDesktopAPI type definition file ==="
rg "containerDesktopAPI\|declare.*type" packages/preload/src --type ts -B 2 -A 10 | head -80

echo
echo "=== Searching for ANY type declarations in the preload file around workspace methods ==="
sed -n '400,450p' packages/preload/src/index.ts

Repository: kortex-hub/kortex

Length of output: 177


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking root package.json workspaces ==="
cat package.json | head -50

echo
echo "=== Looking at lines around 409-435 in preload index.ts ==="
sed -n '405,440p' packages/preload/src/index.ts

echo
echo "=== Searching for type declarations or interfaces that expose preload methods ==="
rg "listAgentWorkspaces\|getAgentWorkspace\|createAgentWorkspace\|startAgentWorkspace\|stopAgentWorkspace\|deleteAgentWorkspace" packages --type ts -B 2 -A 2

echo
echo "=== Looking for how containerDesktopAPI types are created ==="
rg "type.*containerDesktopAPI\|interface.*containerDesktopAPI" packages --type ts

Repository: kortex-hub/kortex

Length of output: 5541


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking if exposedInMainWorld.d.ts exists ==="
ls -la packages/preload/exposedInMainWorld.d.ts 2>/dev/null || echo "File does not exist"

echo
echo "=== Checking what dts-cb tool is ==="
rg "dts-cb" . --type json | head -10

echo
echo "=== Looking at preload tsconfig.json ==="
cat packages/preload/tsconfig.json

echo
echo "=== Checking if there's any type generation in build outputs ==="
find . -path "./dist" -prune -o -name "exposedInMainWorld.d.ts" -type f -print 2>/dev/null

Repository: kortex-hub/kortex

Length of output: 1109


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Checking dts-cb package in package.json ==="
rg "dts-cb" . --type json -A 1 -B 1 | head -20

echo
echo "=== Checking if dts-cb is installed/available ==="
which dts-cb || echo "dts-cb not in PATH"

echo
echo "=== Verifying the 6 workspace methods are in preload source ==="
grep -n "listAgentWorkspaces\|getAgentWorkspace\|createAgentWorkspace\|startAgentWorkspace\|stopAgentWorkspace\|deleteAgentWorkspace" packages/preload/src/index.ts | head -10

Repository: kortex-hub/kortex

Length of output: 1357


Ensure generated preload typings include the new Agent Workspace APIs.

The six workspace methods (listAgentWorkspaces, getAgentWorkspace, createAgentWorkspace, startAgentWorkspace, stopAgentWorkspace, deleteAgentWorkspace) are exposed at runtime via contextBridge.exposeInMainWorld() in packages/preload/src/index.ts, but the generated type declaration file (packages/preload/exposedInMainWorld.d.ts) does not currently exist. Renderer TypeScript consumers need these method signatures in the generated exposedInMainWorld.d.ts to access proper type definitions. Verify that running pnpm run build:preload:types generates this file with all six workspace method declarations included.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/preload/src/index.ts` around lines 409 - 435, The generated preload
type declarations are missing the six Agent Workspace APIs exposed via
contextBridge in index.ts; update the preload type generation so
packages/preload/exposedInMainWorld.d.ts includes type signatures for
listAgentWorkspaces, getAgentWorkspace, createAgentWorkspace,
startAgentWorkspace, stopAgentWorkspace, and deleteAgentWorkspace (matching
AgentWorkspaceInfo and AgentWorkspaceCreateOptions types). Modify the
type-generation entry (the code that emits exposedInMainWorld.d.ts) to pick up
the new exports from packages/preload/src/index.ts and then run/verify the build
task (pnpm run build:preload:types) to ensure the file is created and contains
the exact method signatures exposedInMainWorld expects.

@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 49.20635% with 64 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lugin/agent-workspace/agent-workspace-mock-data.ts 6.12% 46 Missing ⚠️
.../plugin/agent-workspace/agent-workspace-manager.ts 84.21% 9 Missing ⚠️
packages/preload/src/index.ts 47.05% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@MarsKubeX MarsKubeX requested a review from feloy March 5, 2026 15:03
@MarsKubeX MarsKubeX marked this pull request as draft March 5, 2026 15:56
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
…en running stopping

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
…ck file and align with CLI

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
@MarsKubeX MarsKubeX force-pushed the feat/agent-workspaces-manager branch from dd65415 to 184b147 Compare March 9, 2026 11:52
@MarsKubeX
Copy link
Contributor Author

Added 2 commits that:

  • Reworked the agent workspace manager to align with the CLI architecture. Each manager method now delegates to a dedicated mock function (one per CLI command), instead of maintaining internal state. This makes the manager ready to swap mock calls for real exec('kortex', [...]) invocations when the CLI is available.
  • Separated types by concern: AgentWorkspaceSummary (card/list data), AgentWorkspaceStatus (live state + context), AgentWorkspaceCreateOptions (creation input), and AgentWorkspaceInfo (full detail page). Fields not yet returned by the CLI are marked as optional.
  • Externalized mock data into agent-workspace-mock-data.ts, organized by CLI endpoint (list, status, inspect, create, start, stop, delete).
  • Added @kortex-hub/kortex-cli-api dependency. AgentWorkspaceSummary now extends components['schemas']['Workspace'] from the CLI types package, keeping the interface in sync with the CLI contract.

@MarsKubeX MarsKubeX marked this pull request as ready for review March 9, 2026 12:03

import type { components } from '@kortex-hub/kortex-cli-api';

export type AgentType = 'claude' | 'cursor' | 'goose';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it can't really be coded in the UI, I would guess the cli is giving the available supported providers

Copy link
Contributor

@feloy feloy Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can have a mock for the moment, mocking kortex-cli workspace supported-agents or similar command (kortex-hub/kortex-cli#35)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benoitf Changed to have a getSupportedAgents function that will get supported agents from CLI

skills: string[];
mcpServers: string[];
};
createdAt?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it go first in the spec rather than diverging from the spec ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benoitf Removed from the interface definition. Now the interface matches the CLI spec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarsKubeX but it's still part of

export interface AgentWorkspaceInfo extends AgentWorkspaceSummary, AgentWorkspaceStatus {
  fileAccess?: FileAccessLevel;
  customPaths?: string[];
  stats?: {
    messages: number;
    toolCalls: number;
    filesModified: number;
    linesChanged: number;
  };
}

I would expect that UI is not defining anything that is not provided by the CLI

…ynamic agent type

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
@MarsKubeX MarsKubeX requested a review from benoitf March 9, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a mock component to manage agent workspaces

4 participants