MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / finishProcessing

Function finishProcessing

worker/model-worker.ts:69–105  ·  view source on GitHub ↗
(
  responseFile: string,
  requestId: string,
  success: boolean,
  data?: any,
  error?: string,
  callback?: () => void
)

Source from the content-addressed store, hash-verified

67let processing = false;
68
69function finishProcessing(
70 responseFile: string,
71 requestId: string,
72 success: boolean,
73 data?: any,
74 error?: string,
75 callback?: () => void
76) {
77 try {
78 const responseFileLen = view[RESPONSE_FILENAME_LENGTH_INDEX];
79 if (responseFileLen > 0 && responseFileLen <= FILENAME_MAX_LENGTH) {
80 const responseFilePath = join(tmpDir, responseFile);
81
82 const finalResponse = {
83 requestId,
84 success,
85 data: success ? data : undefined,
86 error: error,
87 };
88
89 const encryptedResponse = encrypt(JSON.stringify(finalResponse), aesKey);
90 writeFileSync(responseFilePath, encryptedResponse);
91
92 Atomics.or(view, 0, 0b010);
93 Atomics.notify(view, 0);
94
95 if (callback) {
96 callback();
97 }
98 }
99 } catch (err) {
100 log('error', `[Worker] Failed to write response file: ${err}`);
101 } finally {
102 processing = false;
103 Atomics.and(view, 0, ~0b001);
104 }
105}
106
107async function processRequestAsync(): Promise<void> {
108 let requestFile = '';

Callers 1

processRequestAsyncFunction · 0.85

Calls 2

encryptFunction · 0.90
logFunction · 0.85

Tested by

no test coverage detected