MCPcopy Index your code
hub / github.com/github/copilot-sdk / extractTransformCallbacks

Function extractTransformCallbacks

nodejs/src/client.ts:303–335  ·  view source on GitHub ↗

* Extract transform callbacks from a system message config and prepare the wire payload. * Function-valued actions are replaced with `{ action: "transform" }` for serialization, * and the original callbacks are returned in a separate map.

(systemMessage: SessionConfig["systemMessage"])

Source from the content-addressed store, hash-verified

301 * and the original callbacks are returned in a separate map.
302 */
303function extractTransformCallbacks(systemMessage: SessionConfig["systemMessage"]): {
304 wirePayload: SessionConfig["systemMessage"];
305 transformCallbacks: Map<string, SectionTransformFn> | undefined;
306} {
307 if (!systemMessage || systemMessage.mode !== "customize" || !systemMessage.sections) {
308 return { wirePayload: systemMessage, transformCallbacks: undefined };
309 }
310
311 const transformCallbacks = new Map<string, SectionTransformFn>();
312 const wireSections: Record<string, { action: string; content?: string }> = {};
313
314 for (const [sectionId, override] of Object.entries(systemMessage.sections)) {
315 if (!override) continue;
316
317 if (typeof override.action === "function") {
318 transformCallbacks.set(sectionId, override.action);
319 wireSections[sectionId] = { action: "transform" };
320 } else {
321 wireSections[sectionId] = { action: override.action, content: override.content };
322 }
323 }
324
325 if (transformCallbacks.size === 0) {
326 return { wirePayload: systemMessage, transformCallbacks: undefined };
327 }
328
329 const wirePayload: SystemMessageCustomizeConfig = {
330 ...systemMessage,
331 sections: wireSections as SystemMessageCustomizeConfig["sections"],
332 };
333
334 return { wirePayload, transformCallbacks };
335}
336
337function getNodeExecPath(): string {
338 if (process.versions.bun) {

Callers 2

createSessionMethod · 0.70
resumeSessionMethod · 0.70

Calls 1

setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…