MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / appendAccountRunHistoryTextFile

Function appendAccountRunHistoryTextFile

background/account-run-history.js:85–131  ·  view source on GitHub ↗
(record, stateOverride = null)

Source from the content-addressed store, hash-verified

83 }
84
85 async function appendAccountRunHistoryTextFile(record, stateOverride = null) {
86 const normalizedRecord = record && typeof record === 'object'
87 ? record
88 : buildAccountRunHistoryRecord(stateOverride || await getState(), '');
89 if (!normalizedRecord?.email || !normalizedRecord?.password || !normalizedRecord?.status) {
90 return null;
91 }
92
93 const state = stateOverride || await getState();
94 if (!shouldAppendAccountRunTextFile(state)) {
95 return null;
96 }
97
98 const helperBaseUrl = normalizeAccountRunHistoryHelperBaseUrl(state.accountRunHistoryHelperBaseUrl);
99 let response;
100 try {
101 response = await fetch(buildLocalHelperEndpoint(helperBaseUrl, '/append-account-log'), {
102 method: 'POST',
103 headers: {
104 'Content-Type': 'application/json',
105 Accept: 'application/json',
106 },
107 body: JSON.stringify({
108 email: normalizedRecord.email,
109 password: normalizedRecord.password,
110 status: normalizedRecord.status,
111 recordedAt: normalizedRecord.recordedAt,
112 reason: normalizedRecord.reason || '',
113 }),
114 });
115 } catch (err) {
116 throw new Error(`账号文本记录写入失败:无法连接本地 helper(${getErrorMessage(err)})`);
117 }
118
119 let payload = null;
120 try {
121 payload = await response.json();
122 } catch (err) {
123 throw new Error(`账号文本记录写入失败:本地 helper 返回了无法解析的响应(${getErrorMessage(err)})`);
124 }
125
126 if (!response.ok || payload?.ok === false) {
127 throw new Error(`账号文本记录写入失败:${payload?.error || `HTTP ${response.status}`}`);
128 }
129
130 return payload?.filePath || '';
131 }
132
133 async function appendAccountRunRecord(status, stateOverride = null, reason = '') {
134 const state = stateOverride || await getState();

Callers 1

appendAccountRunRecordFunction · 0.85

Calls 5

getStateFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected