MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / fetchOrgIdForSession

Function fetchOrgIdForSession

services/cloud-agent-next/src/balance-validation.ts:116–130  ·  view source on GitHub ↗
(
  env: PersistenceEnv,
  userId: string,
  sessionId: string
)

Source from the content-addressed store, hash-verified

114 }
115
116 if (!response.ok) {
117 logger
118 .withFields({ status: response.status, statusText: response.statusText })
119 .error('Balance API returned error');
120 return { success: false, status: 500, message: 'Failed to verify balance' };
121 }
122
123 let data: { balance: number; isDepleted: boolean };
124 try {
125 data = await response.json();
126 } catch {
127 return { success: false, status: 500, message: 'Invalid balance response' };
128 }
129
130 if (data.isDepleted || typeof data.balance !== 'number' || data.balance < MIN_BALANCE_DOLLARS) {
131 return { success: false, status: 402, message: 'Insufficient credits: $1 minimum required' };
132 }
133

Callers 2

Calls 2

fetchSessionMetadataFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected