Skip to content

Commit 9dda672

Browse files
skulidropekclaude
andcommitted
feat(api): add auth/state/scrap/sessions/mcp-playwright endpoints
- Add REST endpoints for all CLI commands: /auth/github, /auth/codex, /auth/claude, /state/*, /scrap/*, /sessions/*, /mcp-playwright, /projects/down-all, /projects/:id/apply - Add captureLogOutput utility to capture Effect.log output as response body - POST /projects/down-all placed before parametric /:projectId routes - INVARIANT: ∀ cmd ∈ CLICommands \ {Attach, Panes, Menu}: ∃ endpoint: API handles cmd Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 924b7fa commit 9dda672

10 files changed

Lines changed: 897 additions & 3 deletions

File tree

packages/api/src/api/contracts.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,118 @@ export type ApiEvent = {
227227
readonly at: string
228228
readonly payload: unknown
229229
}
230+
231+
// Auth
232+
export type AuthStatusResponse = { readonly message: string }
233+
234+
export type AuthGithubLoginRequest = {
235+
readonly label?: string | null | undefined
236+
readonly token?: string | null | undefined
237+
readonly scopes?: string | null | undefined
238+
readonly envGlobalPath: string
239+
}
240+
241+
export type AuthGithubStatusRequest = {
242+
readonly envGlobalPath: string
243+
}
244+
245+
export type AuthGithubLogoutRequest = {
246+
readonly label?: string | null | undefined
247+
readonly envGlobalPath: string
248+
}
249+
250+
export type AuthCodexLoginRequest = {
251+
readonly label?: string | null | undefined
252+
readonly codexAuthPath: string
253+
}
254+
255+
export type AuthCodexStatusRequest = {
256+
readonly label?: string | null | undefined
257+
readonly codexAuthPath: string
258+
}
259+
260+
export type AuthCodexLogoutRequest = {
261+
readonly label?: string | null | undefined
262+
readonly codexAuthPath: string
263+
}
264+
265+
export type AuthClaudeLoginRequest = {
266+
readonly label?: string | null | undefined
267+
readonly claudeAuthPath: string
268+
}
269+
270+
export type AuthClaudeStatusRequest = {
271+
readonly label?: string | null | undefined
272+
readonly claudeAuthPath: string
273+
}
274+
275+
export type AuthClaudeLogoutRequest = {
276+
readonly label?: string | null | undefined
277+
readonly claudeAuthPath: string
278+
}
279+
280+
// State
281+
export type StateInitRequest = {
282+
readonly repoUrl: string
283+
readonly repoRef?: string | undefined
284+
}
285+
286+
export type StateCommitRequest = {
287+
readonly message: string
288+
}
289+
290+
export type StateSyncRequest = {
291+
readonly message?: string | null | undefined
292+
}
293+
294+
export type StatePathResponse = { readonly path: string }
295+
296+
export type StateOutputResponse = { readonly output: string }
297+
298+
// Scrap
299+
export type ScrapExportRequest = {
300+
readonly projectDir: string
301+
readonly archivePath?: string | undefined
302+
}
303+
304+
export type ScrapImportRequest = {
305+
readonly projectDir: string
306+
readonly archivePath: string
307+
readonly wipe?: boolean | undefined
308+
}
309+
310+
// Sessions
311+
export type SessionsListRequest = {
312+
readonly projectDir: string
313+
readonly includeDefault?: boolean | undefined
314+
}
315+
316+
export type SessionsKillRequest = {
317+
readonly projectDir: string
318+
readonly pid: number
319+
}
320+
321+
export type SessionsLogsRequest = {
322+
readonly projectDir: string
323+
readonly pid: number
324+
readonly lines?: number | undefined
325+
}
326+
327+
export type SessionsOutput = { readonly output: string }
328+
329+
// MCP Playwright
330+
export type McpPlaywrightUpRequest = {
331+
readonly projectDir: string
332+
readonly runUp?: boolean | undefined
333+
}
334+
335+
// Apply (project config)
336+
export type ApplyRequest = {
337+
readonly runUp?: boolean | undefined
338+
readonly gitTokenLabel?: string | undefined
339+
readonly codexTokenLabel?: string | undefined
340+
readonly claudeTokenLabel?: string | undefined
341+
readonly cpuLimit?: string | undefined
342+
readonly ramLimit?: string | undefined
343+
readonly enableMcpPlaywright?: boolean | undefined
344+
}

packages/api/src/api/schema.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,104 @@ export const AgentLogLineSchema = Schema.Struct({
8686
export type CreateProjectRequestInput = Schema.Schema.Type<typeof CreateProjectRequestSchema>
8787
export type CreateAgentRequestInput = Schema.Schema.Type<typeof CreateAgentRequestSchema>
8888
export type CreateFollowRequestInput = Schema.Schema.Type<typeof CreateFollowRequestSchema>
89+
90+
export const AuthGithubLoginRequestSchema = Schema.Struct({
91+
label: Schema.optional(Schema.NullOr(Schema.String)),
92+
token: Schema.optional(Schema.NullOr(Schema.String)),
93+
scopes: Schema.optional(Schema.NullOr(Schema.String)),
94+
envGlobalPath: Schema.String
95+
})
96+
97+
export const AuthGithubStatusRequestSchema = Schema.Struct({
98+
envGlobalPath: Schema.String
99+
})
100+
101+
export const AuthGithubLogoutRequestSchema = Schema.Struct({
102+
label: Schema.optional(Schema.NullOr(Schema.String)),
103+
envGlobalPath: Schema.String
104+
})
105+
106+
export const AuthCodexLoginRequestSchema = Schema.Struct({
107+
label: Schema.optional(Schema.NullOr(Schema.String)),
108+
codexAuthPath: Schema.String
109+
})
110+
111+
export const AuthCodexStatusRequestSchema = Schema.Struct({
112+
label: Schema.optional(Schema.NullOr(Schema.String)),
113+
codexAuthPath: Schema.String
114+
})
115+
116+
export const AuthCodexLogoutRequestSchema = Schema.Struct({
117+
label: Schema.optional(Schema.NullOr(Schema.String)),
118+
codexAuthPath: Schema.String
119+
})
120+
121+
export const AuthClaudeLoginRequestSchema = Schema.Struct({
122+
label: Schema.optional(Schema.NullOr(Schema.String)),
123+
claudeAuthPath: Schema.String
124+
})
125+
126+
export const AuthClaudeStatusRequestSchema = Schema.Struct({
127+
label: Schema.optional(Schema.NullOr(Schema.String)),
128+
claudeAuthPath: Schema.String
129+
})
130+
131+
export const AuthClaudeLogoutRequestSchema = Schema.Struct({
132+
label: Schema.optional(Schema.NullOr(Schema.String)),
133+
claudeAuthPath: Schema.String
134+
})
135+
136+
export const StateInitRequestSchema = Schema.Struct({
137+
repoUrl: Schema.String,
138+
repoRef: OptionalString
139+
})
140+
141+
export const StateCommitRequestSchema = Schema.Struct({
142+
message: Schema.String
143+
})
144+
145+
export const StateSyncRequestSchema = Schema.Struct({
146+
message: Schema.optional(Schema.NullOr(Schema.String))
147+
})
148+
149+
export const ScrapExportRequestSchema = Schema.Struct({
150+
projectDir: Schema.String,
151+
archivePath: OptionalString
152+
})
153+
154+
export const ScrapImportRequestSchema = Schema.Struct({
155+
projectDir: Schema.String,
156+
archivePath: Schema.String,
157+
wipe: OptionalBoolean
158+
})
159+
160+
export const SessionsListRequestSchema = Schema.Struct({
161+
projectDir: Schema.String,
162+
includeDefault: OptionalBoolean
163+
})
164+
165+
export const SessionsKillRequestSchema = Schema.Struct({
166+
projectDir: Schema.String,
167+
pid: Schema.Number
168+
})
169+
170+
export const SessionsLogsRequestSchema = Schema.Struct({
171+
projectDir: Schema.String,
172+
pid: Schema.Number,
173+
lines: Schema.optional(Schema.Number)
174+
})
175+
176+
export const McpPlaywrightUpRequestSchema = Schema.Struct({
177+
projectDir: Schema.String,
178+
runUp: OptionalBoolean
179+
})
180+
181+
export const ApplyRequestSchema = Schema.Struct({
182+
runUp: OptionalBoolean,
183+
gitTokenLabel: OptionalString,
184+
codexTokenLabel: OptionalString,
185+
claudeTokenLabel: OptionalString,
186+
cpuLimit: OptionalString,
187+
ramLimit: OptionalString,
188+
enableMcpPlaywright: OptionalBoolean
189+
})

0 commit comments

Comments
 (0)