MCPcopy
hub / github.com/coder/mux / normalizeTaskSettings

Function normalizeTaskSettings

src/common/types/tasks.ts:104–156  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

102}
103
104export function normalizeTaskSettings(raw: unknown): TaskSettings {
105 const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : ({} as const);
106
107 const maxParallelAgentTasks = clampInt(
108 record.maxParallelAgentTasks,
109 DEFAULT_TASK_SETTINGS.maxParallelAgentTasks,
110 TASK_SETTINGS_LIMITS.maxParallelAgentTasks.min,
111 TASK_SETTINGS_LIMITS.maxParallelAgentTasks.max
112 );
113 const maxTaskNestingDepth = clampInt(
114 record.maxTaskNestingDepth,
115 DEFAULT_TASK_SETTINGS.maxTaskNestingDepth,
116 TASK_SETTINGS_LIMITS.maxTaskNestingDepth.min,
117 TASK_SETTINGS_LIMITS.maxTaskNestingDepth.max
118 );
119
120 const proposePlanImplementReplacesChatHistory =
121 typeof record.proposePlanImplementReplacesChatHistory === "boolean"
122 ? record.proposePlanImplementReplacesChatHistory
123 : (DEFAULT_TASK_SETTINGS.proposePlanImplementReplacesChatHistory ?? false);
124
125 const preserveSubagentsUntilArchive =
126 typeof record.preserveSubagentsUntilArchive === "boolean"
127 ? record.preserveSubagentsUntilArchive
128 : DEFAULT_TASK_SETTINGS.preserveSubagentsUntilArchive;
129
130 const result: TaskSettings = {
131 maxParallelAgentTasks,
132 maxTaskNestingDepth,
133 proposePlanImplementReplacesChatHistory,
134 preserveSubagentsUntilArchive,
135 };
136
137 assert(
138 Number.isInteger(maxParallelAgentTasks),
139 "normalizeTaskSettings: maxParallelAgentTasks must be an integer"
140 );
141 assert(
142 Number.isInteger(maxTaskNestingDepth),
143 "normalizeTaskSettings: maxTaskNestingDepth must be an integer"
144 );
145
146 assert(
147 typeof proposePlanImplementReplacesChatHistory === "boolean",
148 "normalizeTaskSettings: proposePlanImplementReplacesChatHistory must be a boolean"
149 );
150 assert(
151 typeof preserveSubagentsUntilArchive === "boolean",
152 "normalizeTaskSettings: preserveSubagentsUntilArchive must be a boolean"
153 );
154
155 return result;
156}

Callers 14

refreshFunction · 0.90
TasksSectionFunction · 0.90
setMaxParallelAgentTasksFunction · 0.90
setMaxTaskNestingDepthFunction · 0.90
createMockORPCClientFunction · 0.90
tasks.test.tsFile · 0.90
loadConfigOrDefaultMethod · 0.90
removeMethod · 0.90

Calls 2

clampIntFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected