MCPcopy Index your code
hub / github.com/MatterAIOrg/OrbCode / fetchTaskTitle

Function fetchTaskTitle

src/auth/auth.ts:195–226  ·  view source on GitHub ↗
(
  taskId: string,
  token: string,
  maxRetries = 3,
  retryDelayMs = 2000,
)

Source from the content-addressed store, hash-verified

193 * retries a few times. Ported from the extension's fetchTaskTitle.
194 */
195export async function fetchTaskTitle(
196 taskId: string,
197 token: string,
198 maxRetries = 3,
199 retryDelayMs = 2000,
200): Promise<string | null> {
201 if (!token) return null;
202 const url = getUrlFromToken(
203 `https://api.matterai.so/axoncode/meta/${taskId}`,
204 token,
205 );
206
207 for (let attempt = 1; attempt <= maxRetries; attempt++) {
208 try {
209 const response = await fetch(url, {
210 headers: { Authorization: `Bearer ${token}` },
211 signal: AbortSignal.timeout(5000),
212 });
213 if (response.ok) {
214 const data: unknown = await response.json().catch(() => undefined);
215 const title = sanitizeTitle(data);
216 if (title) return title;
217 }
218 } catch {
219 // network/timeout: fall through to retry
220 }
221 if (attempt < maxRetries) {
222 await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
223 }
224 }
225 return null;
226}
227
228export async function fetchBalance(
229 token: string,

Callers 1

AppFunction · 0.85

Calls 2

getUrlFromTokenFunction · 0.85
sanitizeTitleFunction · 0.85

Tested by

no test coverage detected