MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / patchSessionActions

Function patchSessionActions

packages/server/src/openapi/transforms.ts:134–160  ·  view source on GitHub ↗
(paths: Record<string, unknown>)

Source from the content-addressed store, hash-verified

132}
133
134function patchSessionActions(paths: Record<string, unknown>): void {
135 const internalPath = '/api/v1/sessions/{tail}';
136 const pathItem = asRecord(paths[internalPath]);
137 const operation = asRecord(pathItem?.['post']);
138 if (pathItem === undefined || operation === undefined) return;
139
140 for (const action of ['fork', 'compact', 'undo']) {
141 const cloned = cloneRecord(pathItem);
142 replacePathParamName(cloned, 'tail', 'session_id');
143 const clonedOperation = asRecord(cloned['post']);
144 if (clonedOperation !== undefined) {
145 clonedOperation['operationId'] = `runSession${capitalize(action)}Action`;
146 if (action === 'undo') {
147 clonedOperation['requestBody'] = {
148 required: false,
149 content: jsonContent(openApiDocumentJsonSchema(undoSessionRequestSchema)),
150 };
151 setResponse(clonedOperation, '200', {
152 description: 'Session undo response',
153 content: jsonContent(openApiDocumentEnvelopeJsonSchema(undoSessionResponseSchema)),
154 });
155 }
156 }
157 paths[`/api/v1/sessions/{session_id}:${action}`] = cloned;
158 }
159 delete paths[internalPath];
160}
161
162function patchFsAction(paths: Record<string, unknown>): void {
163 const operation = getOperation(paths, '/api/v1/sessions/{session_id}/{tail}', 'post');

Callers 1

transformOpenApiDocumentFunction · 0.85

Calls 8

replacePathParamNameFunction · 0.85
capitalizeFunction · 0.85
jsonContentFunction · 0.85
setResponseFunction · 0.85
asRecordFunction · 0.70
cloneRecordFunction · 0.70

Tested by

no test coverage detected