MCPcopy Index your code
hub / github.com/simstudioai/sim / executeAgiloftRequest

Function executeAgiloftRequest

apps/sim/tools/agiloft/utils.server.ts:107–130  ·  view source on GitHub ↗
(
  params: AgiloftBaseParams,
  buildRequest: (base: string) => AgiloftRequestConfig,
  transformResponse: (response: SecureFetchResponse) => Promise<R>
)

Source from the content-addressed store, hash-verified

105 * Server-only — uses node:dns/promises and node:http(s) via the pinned fetch.
106 */
107export async function executeAgiloftRequest<R extends ToolResponse>(
108 params: AgiloftBaseParams,
109 buildRequest: (base: string) => AgiloftRequestConfig,
110 transformResponse: (response: SecureFetchResponse) => Promise<R>
111): Promise<R> {
112 const resolvedIP = await resolveAgiloftInstance(params.instanceUrl)
113 const token = await agiloftLoginPinned(params, resolvedIP)
114 const base = params.instanceUrl.replace(/\/$/, '')
115
116 try {
117 const req = buildRequest(base)
118 const response = await secureFetchWithPinnedIP(req.url, resolvedIP, {
119 method: req.method,
120 headers: {
121 ...req.headers,
122 Authorization: `Bearer ${token}`,
123 },
124 body: req.body,
125 })
126 return await transformResponse(response)
127 } finally {
128 await agiloftLogoutPinned(params.instanceUrl, params.knowledgeBase, token, resolvedIP)
129 }
130}
131
132export type { SecureFetchResponse }

Callers 1

Calls 5

secureFetchWithPinnedIPFunction · 0.90
resolveAgiloftInstanceFunction · 0.85
agiloftLoginPinnedFunction · 0.85
agiloftLogoutPinnedFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected