-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtaskInput.ts
More file actions
98 lines (94 loc) · 3.58 KB
/
Copy pathtaskInput.ts
File metadata and controls
98 lines (94 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { buildCloudTaskDescription } from "@posthog/core/editor/cloud-prompt";
import type {
Adapter,
CloudMcpServerImport,
CloudMcpServerRelayDesignation,
TaskCreationInput,
WorkspaceMode,
} from "@posthog/shared";
import type { ExecutionMode } from "@posthog/shared/domain-types";
export interface PrepareTaskInputOptions {
selectedDirectory?: string;
selectedRepository?: string | null;
githubIntegrationId?: number;
githubUserIntegrationId?: string;
workspaceMode: WorkspaceMode;
branch?: string | null;
allowRemoteBranchCheckout?: boolean;
reuseExistingWorktree?: boolean;
executionMode?: ExecutionMode;
adapter?: Adapter;
model?: string;
reasoningLevel?: string;
environmentId?: string | null;
sandboxEnvironmentId?: string;
customImageId?: string;
signalReportId?: string;
additionalDirectories?: string[];
channelContext?: string;
channelName?: string;
channelId?: string;
customInstructions?: string;
autoPublishCloudRuns?: boolean;
rtkEnabledCloud?: boolean;
spokenNarration?: boolean;
allowNoRepo?: boolean;
importedMcpServers?: CloudMcpServerImport[];
relayedMcpServers?: CloudMcpServerRelayDesignation[];
}
export function prepareTaskInput(
serializedContent: string,
filePaths: string[],
options: PrepareTaskInputOptions,
): TaskCreationInput {
const isCloud = options.workspaceMode === "cloud";
return {
content: serializedContent,
taskDescription: isCloud
? buildCloudTaskDescription(serializedContent, filePaths)
: undefined,
filePaths,
repoPath: isCloud ? undefined : options.selectedDirectory,
repository: isCloud ? options.selectedRepository : undefined,
githubIntegrationId: options.githubIntegrationId,
githubUserIntegrationId: options.githubUserIntegrationId,
workspaceMode: options.workspaceMode,
branch: options.branch,
allowRemoteBranchCheckout: options.allowRemoteBranchCheckout,
reuseExistingWorktree: options.reuseExistingWorktree,
executionMode: options.executionMode,
adapter: options.adapter,
model: options.model,
reasoningLevel: options.reasoningLevel,
environmentId: options.environmentId ?? undefined,
sandboxEnvironmentId: options.sandboxEnvironmentId,
customImageId: options.customImageId,
cloudPrAuthorshipMode:
options.signalReportId && isCloud ? "user" : undefined,
cloudRunSource:
options.signalReportId && isCloud ? "signal_report" : undefined,
cloudAutoPublish: isCloud ? options.autoPublishCloudRuns : undefined,
cloudRtkEnabled: isCloud ? options.rtkEnabledCloud : undefined,
spokenNarration: isCloud ? options.spokenNarration : undefined,
signalReportId: options.signalReportId,
additionalDirectories: isCloud ? undefined : options.additionalDirectories,
channelContext: options.channelContext,
channelName: options.channelName,
channelId: options.channelId,
customInstructions: isCloud ? options.customInstructions : undefined,
allowNoRepo: options.allowNoRepo,
importedMcpServers: isCloud ? options.importedMcpServers : undefined,
relayedMcpServers: isCloud ? options.relayedMcpServers : undefined,
};
}
const ERROR_TITLES: Record<string, string> = {
repo_detection: "Failed to detect repository",
task_creation: "Failed to create task",
workspace_creation: "Failed to create workspace",
cloud_prompt_preparation: "Failed to prepare cloud attachments",
cloud_run: "Failed to start cloud execution",
agent_session: "Failed to start agent session",
};
export function getErrorTitle(failedStep: string): string {
return ERROR_TITLES[failedStep] ?? "Task creation failed";
}