MCPcopy Create free account
hub / github.com/apache/maka / runConnectionTestEffect

Function runConnectionTestEffect

packages/runtime/src/test-connection.ts:89–120  ·  view source on GitHub ↗
(
  connection: ConnectionEffectConnection,
  apiKey: string,
  options: ConnectionEffectFetchDependency,
  model?: string,
)

Source from the content-addressed store, hash-verified

87}
88
89export async function runConnectionTestEffect(
90 connection: ConnectionEffectConnection,
91 apiKey: string,
92 options: ConnectionEffectFetchDependency,
93 model?: string,
94): Promise<ConnectionTestEffectOutcome> {
95 const t0 = Date.now();
96 try {
97 const result = await testConnectionStrict(connection, apiKey, model, options.fetch, t0);
98 if (result.ok) {
99 if (!result.modelTested || result.latencyMs === undefined) {
100 return { ok: false, error: { kind: 'invalid_response' } };
101 }
102 return {
103 ok: true,
104 modelId: result.modelTested,
105 latencyMs: result.latencyMs,
106 };
107 }
108 return {
109 ok: false,
110 error: classifyConnectionTestResult(result),
111 ...connectionTestMeasurements(result),
112 };
113 } catch (error) {
114 return {
115 ok: false,
116 error: classifyConnectionTestError(error),
117 latencyMs: Date.now() - t0,
118 };
119 }
120}
121
122async function testConnectionStrict(
123 connection: ConnectionEffectConnection,

Callers 1

Calls 5

testConnectionStrictFunction · 0.85
nowMethod · 0.65

Tested by

no test coverage detected