Skip to content

Go implementation of DeepSeek Harness and self-hosted personal agent.

Go
760 B
Raw Blame
// Configuration is an authorization answer, never a chat attachment or upload.
export async function readAuthorizationJSON(file: { size: number; text(): Promise<string> }): Promise<string> {
  if (file.size > 16384) throw new Error('The configuration file must be 16 KB or smaller.')
  let value: unknown
  try { value = JSON.parse((await file.text()).replace(/^\uFEFF/, '')) }
  catch { throw new Error('Select a valid JSON configuration file.') }
  if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Select a valid JSON configuration file.')
  const answer = JSON.stringify(value)
  if (new TextEncoder().encode(answer).byteLength > 16384) throw new Error('The configuration file must be 16 KB or smaller.')
  return answer
}