mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-21 20:18:11 +02:00
code mode initial commit
This commit is contained in:
parent
fcbcc137ca
commit
b2176435bd
39 changed files with 3919 additions and 94 deletions
71
apps/x/packages/shared/src/code-sessions.ts
Normal file
71
apps/x/packages/shared/src/code-sessions.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import z from "zod";
|
||||
import { CodingAgent, ApprovalPolicy } from "./code-mode.js";
|
||||
|
||||
// Shared zod schemas for the Code section: registered projects and coding
|
||||
// sessions. A coding session is backed by a run (session id == run id); the
|
||||
// mutable metadata below lives in its own per-session file.
|
||||
|
||||
export const CodeProject = z.object({
|
||||
id: z.string(),
|
||||
path: z.string(),
|
||||
name: z.string(),
|
||||
addedAt: z.iso.datetime(),
|
||||
});
|
||||
export type CodeProject = z.infer<typeof CodeProject>;
|
||||
|
||||
// Git facts about a project path, used to gate worktree creation in the UI.
|
||||
export const GitRepoInfo = z.object({
|
||||
isGitRepo: z.boolean(),
|
||||
branch: z.string().nullable(),
|
||||
hasCommits: z.boolean(),
|
||||
dirtyCount: z.number(),
|
||||
});
|
||||
export type GitRepoInfo = z.infer<typeof GitRepoInfo>;
|
||||
|
||||
// 'direct': the user's messages go straight to the ACP coding agent.
|
||||
// 'rowboat': Rowboat's copilot LLM orchestrates the agent via code_agent_run.
|
||||
export const CodeSessionMode = z.enum(["direct", "rowboat"]);
|
||||
export type CodeSessionMode = z.infer<typeof CodeSessionMode>;
|
||||
|
||||
// Derived live in the main process from the run event stream; not persisted.
|
||||
export const CodeSessionStatus = z.enum(["working", "needs-you", "idle"]);
|
||||
export type CodeSessionStatus = z.infer<typeof CodeSessionStatus>;
|
||||
|
||||
export const CodeWorktree = z.object({
|
||||
path: z.string(),
|
||||
branch: z.string(),
|
||||
// Branch the original checkout was on when the worktree was created;
|
||||
// merge-back targets whatever the checkout is on at merge time, this is
|
||||
// informational.
|
||||
baseBranch: z.string().nullable(),
|
||||
mergedAt: z.iso.datetime().optional(),
|
||||
removedAt: z.iso.datetime().optional(),
|
||||
});
|
||||
export type CodeWorktree = z.infer<typeof CodeWorktree>;
|
||||
|
||||
export const CodeSession = z.object({
|
||||
id: z.string(), // == runId
|
||||
projectId: z.string(),
|
||||
title: z.string(),
|
||||
agent: CodingAgent,
|
||||
mode: CodeSessionMode,
|
||||
policy: ApprovalPolicy,
|
||||
// Where the agent works: the project path, or the worktree path.
|
||||
cwd: z.string(),
|
||||
worktree: CodeWorktree.optional(),
|
||||
createdAt: z.iso.datetime(),
|
||||
lastActivityAt: z.iso.datetime().optional(),
|
||||
});
|
||||
export type CodeSession = z.infer<typeof CodeSession>;
|
||||
|
||||
export const GitFileState = z.enum(["modified", "added", "deleted", "untracked", "renamed"]);
|
||||
export type GitFileState = z.infer<typeof GitFileState>;
|
||||
|
||||
export const GitStatusFile = z.object({
|
||||
path: z.string(),
|
||||
state: GitFileState,
|
||||
// Null when git can't compute line counts (binary files).
|
||||
insertions: z.number().nullable(),
|
||||
deletions: z.number().nullable(),
|
||||
});
|
||||
export type GitStatusFile = z.infer<typeof GitStatusFile>;
|
||||
|
|
@ -17,4 +17,5 @@ export * as frontmatter from './frontmatter.js';
|
|||
export * as bases from './bases.js';
|
||||
export * as browserControl from './browser-control.js';
|
||||
export * as billing from './billing.js';
|
||||
export * as codeSessions from './code-sessions.js';
|
||||
export { PrefixLogger };
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ import { ZListToolkitsResponse } from './composio.js';
|
|||
import { BrowserStateSchema } from './browser-control.js';
|
||||
import { BillingInfoSchema } from './billing.js';
|
||||
import { EmailBlockSchema, GmailThreadSchema } from './blocks.js';
|
||||
import { PermissionDecision, ApprovalPolicy } from './code-mode.js';
|
||||
import { PermissionDecision, ApprovalPolicy, CodingAgent } from './code-mode.js';
|
||||
import { CodeProject, CodeSession, CodeSessionMode, CodeSessionStatus, GitRepoInfo, GitStatusFile } from './code-sessions.js';
|
||||
|
||||
// ============================================================================
|
||||
// Runtime Validation Schemas (Single Source of Truth)
|
||||
|
|
@ -231,6 +232,10 @@ const ipcSchemas = {
|
|||
voiceOutput: z.enum(['summary', 'full']).optional(),
|
||||
searchEnabled: z.boolean().optional(),
|
||||
codeMode: z.enum(['claude', 'codex']).optional(),
|
||||
// Code-section sessions pin the coding agent's working directory and
|
||||
// approval policy for the whole turn (see code_agent_run overrides).
|
||||
codeCwd: z.string().optional(),
|
||||
codePolicy: ApprovalPolicy.optional(),
|
||||
middlePaneContext: z.discriminatedUnion('kind', [
|
||||
z.object({
|
||||
kind: z.literal('note'),
|
||||
|
|
@ -460,6 +465,169 @@ const ipcSchemas = {
|
|||
codex: z.object({ installed: z.boolean(), signedIn: z.boolean() }),
|
||||
}),
|
||||
},
|
||||
// ==========================================================================
|
||||
// Code section: project registry + coding sessions
|
||||
// ==========================================================================
|
||||
'codeProject:add': {
|
||||
req: z.object({
|
||||
path: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
project: CodeProject,
|
||||
git: GitRepoInfo,
|
||||
}),
|
||||
},
|
||||
'codeProject:remove': {
|
||||
req: z.object({
|
||||
projectId: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
success: z.literal(true),
|
||||
}),
|
||||
},
|
||||
'codeProject:list': {
|
||||
req: z.null(),
|
||||
res: z.object({
|
||||
projects: z.array(z.object({
|
||||
project: CodeProject,
|
||||
git: GitRepoInfo,
|
||||
})),
|
||||
}),
|
||||
},
|
||||
'codeSession:create': {
|
||||
req: z.object({
|
||||
projectId: z.string(),
|
||||
title: z.string().optional(),
|
||||
agent: CodingAgent,
|
||||
mode: CodeSessionMode,
|
||||
policy: ApprovalPolicy,
|
||||
isolation: z.enum(['in-repo', 'worktree']),
|
||||
}),
|
||||
res: z.object({
|
||||
session: CodeSession,
|
||||
}),
|
||||
},
|
||||
'codeSession:list': {
|
||||
req: z.null(),
|
||||
res: z.object({
|
||||
sessions: z.array(CodeSession),
|
||||
statuses: z.record(z.string(), CodeSessionStatus),
|
||||
}),
|
||||
},
|
||||
'codeSession:update': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
patch: CodeSession.pick({ title: true, mode: true, policy: true, agent: true }).partial(),
|
||||
}),
|
||||
res: z.object({
|
||||
session: CodeSession,
|
||||
}),
|
||||
},
|
||||
'codeSession:delete': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
removeWorktree: z.boolean().optional(),
|
||||
deleteBranch: z.boolean().optional(),
|
||||
}),
|
||||
res: z.object({
|
||||
success: z.literal(true),
|
||||
}),
|
||||
},
|
||||
// Direct-drive: send the user's message straight to the session's ACP agent
|
||||
// (no copilot LLM in between). Streams back over `runs:events`.
|
||||
'codeSession:sendMessage': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
text: z.string().min(1),
|
||||
}),
|
||||
res: z.object({
|
||||
accepted: z.boolean(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
'codeSession:stop': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
success: z.literal(true),
|
||||
}),
|
||||
},
|
||||
'codeSession:gitStatus': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
isRepo: z.boolean(),
|
||||
branch: z.string().nullable(),
|
||||
hasCommits: z.boolean(),
|
||||
files: z.array(GitStatusFile),
|
||||
}),
|
||||
},
|
||||
'codeSession:fileDiff': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
path: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
oldText: z.string(),
|
||||
newText: z.string(),
|
||||
isBinary: z.boolean(),
|
||||
tooLarge: z.boolean(),
|
||||
}),
|
||||
},
|
||||
'codeSession:readdir': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
relPath: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
entries: z.array(z.object({
|
||||
name: z.string(),
|
||||
kind: z.enum(['file', 'dir']),
|
||||
size: z.number().optional(),
|
||||
})),
|
||||
}),
|
||||
},
|
||||
'codeSession:readFile': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
relPath: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
content: z.string(),
|
||||
isBinary: z.boolean(),
|
||||
tooLarge: z.boolean(),
|
||||
}),
|
||||
},
|
||||
'codeSession:mergeBack': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
}),
|
||||
res: z.object({
|
||||
ok: z.boolean(),
|
||||
conflict: z.boolean().optional(),
|
||||
message: z.string(),
|
||||
}),
|
||||
},
|
||||
'codeSession:cleanupWorktree': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
deleteBranch: z.boolean(),
|
||||
}),
|
||||
res: z.object({
|
||||
success: z.boolean(),
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
// main → renderer: live session status transitions from the status tracker.
|
||||
'codeSession:status': {
|
||||
req: z.object({
|
||||
sessionId: z.string(),
|
||||
status: CodeSessionStatus,
|
||||
}),
|
||||
res: z.null(),
|
||||
},
|
||||
'granola:setConfig': {
|
||||
req: z.object({
|
||||
enabled: z.boolean(),
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export const StartEvent = BaseRunEvent.extend({
|
|||
"background_task_agent",
|
||||
"meeting_note",
|
||||
"knowledge_sync",
|
||||
"code_session",
|
||||
]).optional(),
|
||||
subUseCase: z.string().optional(),
|
||||
});
|
||||
|
|
@ -188,6 +189,7 @@ export const UseCase = z.enum([
|
|||
"background_task_agent",
|
||||
"meeting_note",
|
||||
"knowledge_sync",
|
||||
"code_session",
|
||||
]);
|
||||
|
||||
export const Run = z.object({
|
||||
|
|
@ -209,6 +211,7 @@ export const ListRunsResponse = z.object({
|
|||
title: true,
|
||||
createdAt: true,
|
||||
agentId: true,
|
||||
useCase: true,
|
||||
})),
|
||||
nextCursor: z.string().optional(),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue