MCPcopy Create free account
hub / github.com/ColeMurray/background-agents / createSession

Function createSession

packages/github-bot/src/handlers.ts:38–79  ·  view source on GitHub ↗
(
  controlPlane: Fetcher,
  headers: Record<string, string>,
  params: {
    repoOwner: string;
    repoName: string;
    title: string;
    model: string;
    reasoningEffort?: string | null;
    scmLogin: string;
    scmUserId: string;
    scmAvatarUrl: string;
  }
)

Source from the content-addressed store, hash-verified

36 params: {
37 target: SessionTargetFields;
38 title: string;
39 model: string;
40 reasoningEffort?: string | null;
41 scmLogin: string;
42 scmUserId: string;
43 scmAvatarUrl: string;
44 }
45): Promise<string> {
46 const body: Record<string, unknown> = {
47 ...params.target,
48 title: params.title,
49 model: params.model,
50 scmLogin: params.scmLogin,
51 scmAvatarUrl: params.scmAvatarUrl,
52 };
53 if (params.reasoningEffort) {
54 body.reasoningEffort = params.reasoningEffort;
55 }
56 const url = "https://internal/sessions";
57 const bodyText = JSON.stringify(body);
58 const response = await signedControlPlaneFetch(env, {
59 method: "POST",
60 url,
61 body: bodyText,
62 actor: `github:${params.scmUserId}`,
63 traceId,
64 });
65 if (!response.ok) {
66 const body = await response.text();
67 throw new Error(`Session creation failed: ${response.status} ${body}`);
68 }
69 const result = createSessionResponseSchema.safeParse(await response.json());
70 if (!result.success) {
71 throw new Error("Session creation failed: invalid response");
72 }
73 return result.data.sessionId;
74}
75
76async function sendPrompt(
77 env: Env,
78 traceId: string,
79 sessionId: string,
80 params: { content: string; authorId: string }
81): Promise<string> {
82 const url = `https://internal/sessions/${sessionId}/prompt`;

Callers 4

handleReviewRequestedFunction · 0.70
handlePullRequestOpenedFunction · 0.70
handleIssueCommentFunction · 0.70
handleReviewCommentFunction · 0.70

Calls 2

fetchMethod · 0.65
jsonMethod · 0.45

Tested by

no test coverage detected