Skip to content
Merged
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
3 changes: 0 additions & 3 deletions apps/dashboard/src/components/AuthGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';

import { setSessionMode } from '../api/client.js';

type AuthMode = 'loading' | 'authenticated' | 'create-account' | 'login';

interface SetupStatus {
Expand All @@ -28,7 +26,6 @@ export function AuthGate({ children }: { children: React.ReactNode }) {
async function checkAuth() {
// Check setup status
// Check OIDC session first (before setup status, to avoid redirect loops)
let isOidcAuthenticated = false;
try {
const meRes = await fetch('/auth/me', { credentials: 'include' });
if (meRes.ok) {
Expand Down
14 changes: 14 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/domains/daemon/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface StoredDaemon {
status: DaemonStatus;
snapshot: string;
trigger: Trigger;
workspace?: string | undefined;
Copy link
Copy Markdown

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
# Verify the interface mismatch in control-plane store

echo "=== StoredDaemon interface in control-plane ==="
rg -n -A 20 'export interface StoredDaemon' apps/control-plane/src/store/daemons.ts

echo ""
echo "=== createDaemonStore create method ==="
rg -n -A 25 'create\(request\)' apps/control-plane/src/store/daemons.ts

echo ""
echo "=== Check if workspace exists anywhere in control-plane daemons store ==="
rg -n 'workspace' apps/control-plane/src/store/daemons.ts

Repository: arek-e/paws

Length of output: 2553


Control-plane store implementations are missing the workspace field.

The workspace field is correctly added to StoredDaemon and the create() method here (line 50), but the control-plane has a separate StoredDaemon interface and store implementations in apps/control-plane/src/store/daemons.ts that don't include this field.

Update required:

  • Add workspace?: string | undefined to the StoredDaemon interface (line 12)
  • Add workspace: request.workspace to the in-memory store's create() method (line 48)
  • Add workspace to the SQLite store's insert statement (line 150-163)

Without these changes, the workspace value will be silently dropped when daemons are created through the control-plane.

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

In `@packages/domains/daemon/src/store.ts` at line 13, StoredDaemon in the
control-plane store is missing the workspace field so workspace is dropped;
update the StoredDaemon interface to include workspace?: string | undefined,
modify the in-memory store create() implementation to set workspace:
request.workspace when building the stored object in the create() method, and
update the SQLite store insert statement to include the workspace column and
bind request.workspace in the values for the insert (adjust the INSERT SQL and
parameter list in the SQLite store implementation accordingly).

workload?: Workload | undefined;
agent?: AgentConfig | undefined;
resources?: Resources | undefined;
Expand Down Expand Up @@ -46,6 +47,7 @@ export function createDaemonStore(): DaemonStore {
status: 'active',
snapshot: request.snapshot,
trigger: request.trigger,
workspace: request.workspace,
workload: request.workload,
agent: request.agent,
resources: request.resources,
Expand Down
3 changes: 3 additions & 0 deletions packages/domains/daemon/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const CreateDaemonRequestSchema = z
description: z.string().default(''),
snapshot: NonEmptyStringSchema,
trigger: TriggerSchema,
/** Workspace this daemon belongs to */
workspace: z.string().optional(),
/** Workload script — required unless agent is configured */
workload: WorkloadSchema.optional(),
/** Agent framework config — auto-generates the workload script */
Expand Down Expand Up @@ -120,6 +122,7 @@ export const DaemonListItemSchema = z.object({
status: DaemonStatus,
trigger: TriggerSchema,
stats: DaemonStatsSchema,
workspace: z.string().optional(),
});

export type DaemonListItem = z.infer<typeof DaemonListItemSchema>;
Expand Down
25 changes: 25 additions & 0 deletions packages/domains/workspace/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@paws/domain-workspace",
"version": "0.1.0",
"private": true,
"description": "Workspace domain — Workspace, WorkspaceStore, routes",
"type": "module",
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts"
}
},
"scripts": {
"test": "vitest run --passWithNoTests",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@hono/zod-openapi": "catalog:",
"@paws/domain-common": "workspace:*",
"zod": "catalog:"
},
"devDependencies": {
"vitest": "catalog:"
}
}
27 changes: 27 additions & 0 deletions packages/domains/workspace/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export {
CreateWorkspaceRequestSchema,
UpdateWorkspaceRequestSchema,
WorkspaceListResponseSchema,
WorkspaceRepoSchema,
WorkspaceSchema,
WorkspaceSettingsSchema,
} from './types.js';
export type {
CreateWorkspaceRequest,
UpdateWorkspaceRequest,
Workspace,
WorkspaceListResponse,
WorkspaceRepo,
WorkspaceSettings,
} from './types.js';

export { createWorkspaceStore } from './store.js';
export type { WorkspaceStore } from './store.js';

export {
createWorkspaceRoute,
deleteWorkspaceRoute,
getWorkspaceRoute,
listWorkspacesRoute,
updateWorkspaceRoute,
} from './routes.js';
120 changes: 120 additions & 0 deletions packages/domains/workspace/src/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { createRoute, z } from '@hono/zod-openapi';
import { ErrorResponseSchema } from '@paws/domain-common';
import {
CreateWorkspaceRequestSchema,
UpdateWorkspaceRequestSchema,
WorkspaceListResponseSchema,
WorkspaceSchema,
} from './types.js';

export const createWorkspaceRoute = createRoute({
method: 'post',
path: '/v1/workspaces',
tags: ['Workspaces'],
request: {
body: {
content: {
'application/json': {
schema: CreateWorkspaceRequestSchema,
},
},
},
},
responses: {
201: {
description: 'Workspace created',
content: { 'application/json': { schema: WorkspaceSchema } },
},
400: {
description: 'Validation error',
content: { 'application/json': { schema: ErrorResponseSchema } },
},
409: {
description: 'Workspace name already exists',
content: { 'application/json': { schema: ErrorResponseSchema } },
},
},
});

export const listWorkspacesRoute = createRoute({
method: 'get',
path: '/v1/workspaces',
tags: ['Workspaces'],
responses: {
200: {
description: 'List of workspaces',
content: { 'application/json': { schema: WorkspaceListResponseSchema } },
},
},
});

export const getWorkspaceRoute = createRoute({
method: 'get',
path: '/v1/workspaces/{id}',
tags: ['Workspaces'],
request: {
params: z.object({ id: z.string().min(1) }),
},
responses: {
200: {
description: 'Workspace detail',
content: { 'application/json': { schema: WorkspaceSchema } },
},
404: {
description: 'Workspace not found',
content: { 'application/json': { schema: ErrorResponseSchema } },
},
},
});

export const updateWorkspaceRoute = createRoute({
method: 'put',
path: '/v1/workspaces/{id}',
tags: ['Workspaces'],
request: {
params: z.object({ id: z.string().min(1) }),
body: {
content: {
'application/json': {
schema: UpdateWorkspaceRequestSchema,
},
},
},
},
responses: {
200: {
description: 'Workspace updated',
content: { 'application/json': { schema: WorkspaceSchema } },
},
404: {
description: 'Workspace not found',
content: { 'application/json': { schema: ErrorResponseSchema } },
},
},
});

export const deleteWorkspaceRoute = createRoute({
method: 'delete',
path: '/v1/workspaces/{id}',
tags: ['Workspaces'],
request: {
params: z.object({ id: z.string().min(1) }),
},
responses: {
200: {
description: 'Workspace deleted',
content: {
'application/json': {
schema: z.object({
id: z.string(),
deleted: z.literal(true),
}),
},
},
},
404: {
description: 'Workspace not found',
content: { 'application/json': { schema: ErrorResponseSchema } },
},
},
});
57 changes: 57 additions & 0 deletions packages/domains/workspace/src/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { CreateWorkspaceRequest, Workspace } from './types.js';

export interface WorkspaceStore {
create(workspace: Workspace): Workspace;
get(id: string): Workspace | undefined;
getByName(name: string): Workspace | undefined;
list(): Workspace[];
update(id: string, partial: Partial<CreateWorkspaceRequest>): Workspace | undefined;
delete(id: string): boolean;
}

/** In-memory workspace store */
export function createWorkspaceStore(): WorkspaceStore {
const workspaces = new Map<string, Workspace>();

return {
create(workspace) {
workspaces.set(workspace.id, workspace);
return workspace;
},

get(id) {
return workspaces.get(id);
},

getByName(name) {
for (const workspace of workspaces.values()) {
if (workspace.name === name) return workspace;
}
return undefined;
},

list() {
return [...workspaces.values()];
},

update(id, partial) {
const workspace = workspaces.get(id);
if (!workspace) return undefined;
const updated: Workspace = {
...workspace,
...(partial.name !== undefined && { name: partial.name }),
...(partial.description !== undefined && { description: partial.description }),
...(partial.type !== undefined && { type: partial.type }),
...(partial.repos !== undefined && { repos: partial.repos }),
...(partial.settings !== undefined && { settings: partial.settings }),
updatedAt: new Date().toISOString(),
};
workspaces.set(id, updated);
return updated;
},

delete(id) {
return workspaces.delete(id);
},
};
}
Loading
Loading