Skip to content

Commit 59d7ee6

Browse files
committed
docker sandbox working locally
1 parent e514323 commit 59d7ee6

31 files changed

Lines changed: 2531 additions & 2945 deletions

apps/twig/src/api/posthogClient.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,39 @@ export class PostHogAPIClient {
194194
return await response.json();
195195
}
196196

197-
async createTaskRun(taskId: string): Promise<TaskRun> {
197+
async getTaskRunConnectionToken(
198+
taskId: string,
199+
runId: string,
200+
): Promise<{ token: string }> {
201+
const teamId = await this.getTeamId();
202+
const url = new URL(
203+
`${this.api.baseUrl}/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/connection_token/`,
204+
);
205+
const response = await this.api.fetcher.fetch({
206+
method: "get",
207+
url,
208+
path: `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/connection_token/`,
209+
});
210+
211+
if (!response.ok) {
212+
throw new Error(`Failed to fetch connection token: ${response.statusText}`);
213+
}
214+
215+
return await response.json();
216+
}
217+
218+
async createTaskRun(
219+
taskId: string,
220+
environment: "local" | "cloud" = "local",
221+
): Promise<TaskRun> {
198222
const teamId = await this.getTeamId();
199223
const data = await this.api.post(
200224
`/api/projects/{project_id}/tasks/{task_id}/runs/`,
201225
{
202226
path: { project_id: teamId.toString(), task_id: taskId },
203227
//@ts-expect-error the generated client does not infer the request type unless explicitly specified on the viewset
204228
body: {
205-
environment: "local" as const,
229+
environment,
206230
},
207231
},
208232
);

apps/twig/src/main/services/agent/schemas.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ export const sessionConfigSchema = z.object({
1919
taskId: z.string(),
2020
taskRunId: z.string(),
2121
repoPath: z.string(),
22-
credentials: credentialsSchema,
22+
credentials: credentialsSchema.optional(),
2323
logUrl: z.string().optional(),
2424
sdkSessionId: z.string().optional(),
2525
model: z.string().optional(),
2626
executionMode: executionModeSchema.optional(),
2727
/** Additional directories Claude can access beyond cwd (for worktree support) */
2828
additionalDirectories: z.array(z.string()).optional(),
29+
runMode: z.enum(["local", "cloud"]).optional(),
30+
/** Cloud transport config - required when runMode is 'cloud' */
31+
sandboxUrl: z.string().optional(),
32+
connectionToken: z.string().optional(),
2933
});
3034

3135
export type SessionConfig = z.infer<typeof sessionConfigSchema>;
@@ -48,6 +52,9 @@ export const startSessionInput = z.object({
4852
runMode: z.enum(["local", "cloud"]).optional(),
4953
/** Additional directories Claude can access beyond cwd (for worktree support) */
5054
additionalDirectories: z.array(z.string()).optional(),
55+
/** Cloud transport config - required when runMode is 'cloud' */
56+
sandboxUrl: z.string().optional(),
57+
connectionToken: z.string().optional(),
5158
});
5259

5360
export type StartSessionInput = z.infer<typeof startSessionInput>;

0 commit comments

Comments
 (0)